File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1383,7 +1383,7 @@ static ssize_t net_http_receive_header(struct http_t *state, ssize_t len)
13831383 {
13841384 len = response -> pos ;
13851385 response -> pos = 0 ;
1386- if (response -> bodytype == T_LEN )
1386+ if (response -> bodytype == T_LEN && response -> len > 0 )
13871387 {
13881388 /* Use a tmp pointer so a realloc failure does not leak the
13891389 * original buffer AND leave response->data NULL for later
@@ -1428,7 +1428,7 @@ static bool net_http_receive_body(struct http_t *state, ssize_t newlen)
14281428 if (response -> bodytype != T_FULL )
14291429 return false;
14301430 response -> part = P_DONE ;
1431- if (response -> buflen != response -> len )
1431+ if (response -> buflen != response -> len && response -> len > 0 )
14321432 {
14331433 /* Shrink response->data from buflen bytes to len bytes.
14341434 * Use a tmp pointer so a realloc() failure (rare on shrink
@@ -1535,7 +1535,7 @@ static bool net_http_receive_body(struct http_t *state, ssize_t newlen)
15351535 else if (response -> pos == response -> len )
15361536 {
15371537 response -> part = P_DONE ;
1538- if (response -> buflen != response -> len )
1538+ if (response -> buflen != response -> len && response -> len > 0 )
15391539 {
15401540 char * tmp = (char * )realloc (response -> data , response -> len );
15411541 if (!tmp )
You can’t perform that action at this time.
0 commit comments