
cherokee at cherokee-project
May 24, 2011, 9:24 AM
Post #1 of 1
(84 views)
Permalink
|
|
[6714] cherokee/trunk/cherokee/source_interpreter.c: "Pointer 'src-> custom_env' returned from call to function 'malloc' at
|
|
Revision: 6714 http://svn.cherokee-project.com/changeset/6714 Author: alo Date: 2011-05-24 18:24:17 +0200 (Tue, 24 May 2011) Log Message: ----------- "Pointer 'src->custom_env' returned from call to function 'malloc' at line 354 may be NULL and will be dereferenced at line 360. Also there is one similar error on line 360." (Klocwork.com Issue #116) Modified Paths: -------------- cherokee/trunk/cherokee/source_interpreter.c Modified: cherokee/trunk/cherokee/source_interpreter.c =================================================================== --- cherokee/trunk/cherokee/source_interpreter.c 2011-05-24 16:19:19 UTC (rev 6713) +++ cherokee/trunk/cherokee/source_interpreter.c 2011-05-24 16:24:17 UTC (rev 6714) @@ -340,7 +340,7 @@ entry_len = env->len + val->len + 2; entry = (char *) malloc (entry_len); - if (entry == NULL) { + if (unlikely (entry == NULL)) { ret = ret_nomem; goto error; } @@ -355,8 +355,14 @@ } else { src->custom_env = realloc (src->custom_env, (src->custom_env_len + 2) * sizeof (char *)); } + + if (unlikely (src->custom_env == NULL)) { + ret = ret_nomem; + free (entry); + goto error; + } + src->custom_env_len += 1; - src->custom_env[src->custom_env_len - 1] = entry; src->custom_env[src->custom_env_len] = NULL;
|