Skip to content

Commit 028dd66

Browse files
author
Keyur Govande
committed
Check malloc rc (hat-tip Christopher Jones)
1 parent c4c53b6 commit 028dd66

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sapi/cli/ps_title.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ char** save_ps_args(int argc, char** argv)
177177
* move the environment out of the way
178178
*/
179179
new_environ = (char **) malloc((i + 1) * sizeof(char *));
180+
if (!new_environ)
181+
goto clobber_error;
180182
for (i = 0; environ[i] != NULL; i++)
181183
{
182184
new_environ[i] = strdup(environ[i]);
@@ -205,6 +207,8 @@ char** save_ps_args(int argc, char** argv)
205207
int i;
206208

207209
new_argv = (char **) malloc((argc + 1) * sizeof(char *));
210+
if (!new_argv)
211+
goto clobber_error;
208212
for (i = 0; i < argc; i++)
209213
{
210214
new_argv[i] = strdup(argv[i]);

0 commit comments

Comments
 (0)