libsemanage: always check append_arg return value

When split_args() calls append_arg(), the returned value needs to be
checked in order to detect memory allocation failure. Checks were
missing in two places, which are spotted by clang's static analyzer:

    semanage_store.c:1352:7: warning: Value stored to 'rc' is never
    read
            rc = append_arg(&argv, &num_args, arg);
            ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    semanage_store.c:1368:3: warning: Value stored to 'rc' is never read
            rc = append_arg(&argv, &num_args, arg);
            ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
Nicolas Iooss 2018-04-22 21:30:32 +02:00 committed by William Roberts
parent 20a324b591
commit 531fc3d8a7

View File

@ -1350,6 +1350,8 @@ static char **split_args(const char *arg0, char *arg_string,
if (isspace(*s) && !in_quote && !in_dquote) {
if (arg != NULL) {
rc = append_arg(&argv, &num_args, arg);
if (rc)
goto cleanup;
free(arg);
arg = NULL;
}
@ -1366,6 +1368,8 @@ static char **split_args(const char *arg0, char *arg_string,
}
if (arg != NULL) {
rc = append_arg(&argv, &num_args, arg);
if (rc)
goto cleanup;
free(arg);
arg = NULL;
}