end = strchr(header, '\r');
if(!end) {
end = strchr(header, '\n');
- DEBUGASSERT(end);
if(!end)
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ /* neither CR nor LF as terminator is not a valid header */
+ return CURLE_WEIRD_SERVER_REPLY;
}
hlen = end - header;
hs->buffer[hlen] = 0; /* nul terminate */
result = namevalue(hs->buffer, hlen, type, &name, &value);
- if(result)
- goto fail;
-
- hs->name = name;
- hs->value = value;
- hs->type = type;
- hs->request = data->state.requests;
-
- /* insert this node into the list of headers */
- Curl_llist_insert_next(&data->state.httphdrs, data->state.httphdrs.tail,
- hs, &hs->node);
- data->state.prevhead = hs;
- return CURLE_OK;
-fail:
- free(hs);
+ if(!result) {
+ hs->name = name;
+ hs->value = value;
+ hs->type = type;
+ hs->request = data->state.requests;
+
+ /* insert this node into the list of headers */
+ Curl_llist_insert_next(&data->state.httphdrs, data->state.httphdrs.tail,
+ hs, &hs->node);
+ data->state.prevhead = hs;
+ }
+ else
+ free(hs);
return result;
}