Don't store new headers unless ones weren't available

This commit is contained in:
Nick Krichevsky 2018-09-01 16:44:04 -04:00
parent 529b86dade
commit 93ff826f67

View file

@ -60,7 +60,10 @@ static struct line_read_result read_line(const char *buffer, int buffer_size, st
// Must start copying after the :
memcpy(header_value, (buffer + name_size + 1), value_size);
header_value[value_size] = '\0';
message->headers = insert_header(header_name, header_value, message->headers);
struct http_header *new_header = insert_header(header_name, header_value, message->headers);
if (message->headers == NULL) {
message->headers = new_header;
}
free(header_value);
free(header_name);
} else {