If ap_get_brigade() returns APR_SUCCESS but an empty brigade, bail out.
Previously, we kept going and sometimes segfaulted while operating on
what we thought was the first bucket.
Free the temporary brigade used by getline().
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86581
13f79535-47bb-0310-9956-
ffa450edef68
while (1) {
if (AP_BRIGADE_EMPTY(b)) {
- if (ap_get_brigade(c->input_filters, b, AP_GET_LINE) != APR_SUCCESS) {
+ if (ap_get_brigade(c->input_filters, b, AP_GET_LINE) != APR_SUCCESS ||
+ AP_BRIGADE_EMPTY(b)) {
+ ap_brigade_destroy(b);
return -1;
}
}
/* input line was larger than the caller's buffer */
AP_BUCKET_REMOVE(e);
ap_bucket_destroy(e);
+ ap_brigade_destroy(b);
return -1;
}
pos++; /* bump past end of incomplete line */
}
}
+ ap_brigade_destroy(b);
return total;
}