diff options
author | Sergey Mironov <grrwlf@gmail.com> | 2014-08-23 11:59:34 +0000 |
---|---|---|
committer | Sergey Mironov <grrwlf@gmail.com> | 2014-08-23 11:59:34 +0000 |
commit | d04c48b573d36ee7a04ea1b44ec95f79f6a07b6a (patch) | |
tree | 2886379adb6577ecbb04d59665b5734b890c5cc1 /src | |
parent | 883e5277776a1900c8a770816841ef9676addeff (diff) |
Check realloc's return code to prevent segfault on out of memoty condition
Diffstat (limited to 'src')
-rw-r--r-- | src/c/request.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/c/request.c b/src/c/request.c index f212655f..9dc6aa59 100644 --- a/src/c/request.c +++ b/src/c/request.c @@ -444,8 +444,12 @@ request_result uw_request(uw_request_context rc, uw_context ctx, int len = strlen(inputs); if (len+1 > rc->queryString_size) { - rc->queryString_size = len+1; rc->queryString = realloc(rc->queryString, len+1); + if(rc->queryString == NULL) { + log_error(logger_data, "queryString is too long (not enough memory)\n"); + return FAILED; + } + rc->queryString_size = len+1; } strcpy(rc->queryString, inputs); @@ -480,8 +484,12 @@ request_result uw_request(uw_request_context rc, uw_context ctx, on_success(ctx); if (path_len + 1 > rc->path_copy_size) { + rc->path_copy = realloc(rc->path_copy, path_len + 1); + if(rc->path_copy == NULL) { + log_error(logger_data, "Path is too long (not enough memory)\n"); + return FAILED; + } rc->path_copy_size = path_len + 1; - rc->path_copy = realloc(rc->path_copy, rc->path_copy_size); } strcpy(rc->path_copy, path); |