extra error checking

This commit is contained in:
Christian Grothoff
2007-08-18 09:07:12 +00:00
parent ebbcd54678
commit ef59dec2ca
2 changed files with 19 additions and 0 deletions
+5
View File
@@ -1,3 +1,8 @@
Sat Aug 18 03:06:09 MDT 2007
Check for out of memory when adding headers to
responses. Check for NULL key when looking
for headers. - CG
Wed Aug 15 01:46:44 MDT 2007
Extending API to allow timeout of connections.
Changed API (MHD_create_response_from_callback) to
+14
View File
@@ -50,8 +50,19 @@ MHD_add_response_header (struct MHD_Response *response,
(NULL != strstr (content, "\r")) || (NULL != strstr (content, "\n")))
return MHD_NO;
hdr = malloc (sizeof (struct MHD_HTTP_Header));
if (hdr == NULL)
return MHD_NO;
hdr->header = strdup (header);
if (hdr->header == NULL) {
free(hdr);
return MHD_NO;
}
hdr->value = strdup (content);
if (hdr->value == NULL) {
free(hdr->header);
free(hdr);
return MHD_NO;
}
hdr->kind = MHD_HEADER_KIND;
hdr->next = response->first_header;
response->first_header = hdr;
@@ -132,6 +143,9 @@ const char *
MHD_get_response_header (struct MHD_Response *response, const char *key)
{
struct MHD_HTTP_Header *pos;
if (key == NULL)
return NULL;
pos = response->first_header;
while (pos != NULL)
{