mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
tool_cb_dbg.c: fix tool_cb_dbg() to behave properly even for size 0
curl segfault in debug callback triggered with CURLINFO_HEADER_OUT and size 0 bug: http://curl.haxx.se/bug/view.cgi?id=3511794
This commit is contained in:
parent
459435dca1
commit
4bdb664c33
@ -108,19 +108,21 @@ int tool_debug_cb(CURL *handle, curl_infotype type,
|
||||
|
||||
switch(type) {
|
||||
case CURLINFO_HEADER_OUT:
|
||||
for(i = 0; i < size - 1; i++) {
|
||||
if(data[i] == '\n') { /* LF */
|
||||
if(!newl) {
|
||||
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
|
||||
if(size > 0) {
|
||||
for(i = 0; i < size - 1; i++) {
|
||||
if(data[i] == '\n') { /* LF */
|
||||
if(!newl) {
|
||||
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
|
||||
}
|
||||
(void)fwrite(data + st, i - st + 1, 1, output);
|
||||
st = i + 1;
|
||||
newl = FALSE;
|
||||
}
|
||||
(void)fwrite(data + st, i - st + 1, 1, output);
|
||||
st = i + 1;
|
||||
newl = FALSE;
|
||||
}
|
||||
if(!newl)
|
||||
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
|
||||
(void)fwrite(data + st, i - st + 1, 1, output);
|
||||
}
|
||||
if(!newl)
|
||||
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
|
||||
(void)fwrite(data + st, i - st + 1, 1, output);
|
||||
newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE;
|
||||
traced_data = FALSE;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user