Browse files

Correctly initialize the `value` component of HeaderValue.

  • Loading branch information...
1 parent 86f0fdd commit c713c37b963601f9f7c10563adc55bb8118e4a9f @ovidiucp committed Jan 24, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 TinyWebServer.cpp
View
5 TinyWebServer.cpp
@@ -68,6 +68,7 @@ TinyWebServer::TinyWebServer(PathHandler handlers[],
headers_ = (HeaderValue*)malloc_check(sizeof(HeaderValue) * (size + 1));
for (int i = 0; i < size; i++) {
headers_[i].header = headers[i];
+ headers_[i].value = NULL;
}
headers_[size].header = NULL;
} else {
@@ -84,7 +85,9 @@ boolean TinyWebServer::process_headers() {
if (headers_) {
// First clear the header values from the previous HTTP request
for (int i = 0; headers_[i].header; i++) {
- free(headers_[i].value);
+ if (headers_[i].value) {
+ free(headers_[i].value);
+ }
headers_[i].value = NULL;
}
}

0 comments on commit c713c37

Please sign in to comment.