Currently in ss_execute_command() we're missng a check to see if the memory allocation was succesful. Fix it by adding SS_ET_ENOMEM error and checking the return from malloc. Signed-off-by: Lukas Czerner <lczerner@xxxxxxxxxx> --- lib/ss/execute_cmd.c | 2 ++ lib/ss/ss_err.et | 3 +++ 2 files changed, 5 insertions(+) diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c index d443a468..0bcaa54d 100644 --- a/lib/ss/execute_cmd.c +++ b/lib/ss/execute_cmd.c @@ -171,6 +171,8 @@ int ss_execute_command(int sci_idx, register char *argv[]) for (argp = argv; *argp; argp++) argc++; argp = (char **)malloc((argc+1)*sizeof(char *)); + if (!argp) + return(SS_ET_ENOMEM); for (i = 0; i <= argc; i++) argp[i] = argv[i]; i = really_execute_command(sci_idx, argc, &argp); diff --git a/lib/ss/ss_err.et b/lib/ss/ss_err.et index 80e9dfa4..f7238da0 100644 --- a/lib/ss/ss_err.et +++ b/lib/ss/ss_err.et @@ -36,4 +36,7 @@ ec SS_ET_ESCAPE_DISABLED, ec SS_ET_UNIMPLEMENTED, "Sorry, this request is not yet implemented" +ec SS_ET_ENOMEM, + "Not enough memory" + end -- 2.34.1