Changeset 587867a in mainline for uspace/app/bdsh/compl.c


Ignore:
Timestamp:
2019-03-16T13:01:30Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aeeaf0f
Parents:
1c481ee
Message:

improve error handling

The code did not test if malloc returned NULL.
This meant that the code potentially could break without
that the user was informed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/compl.c

    r1c481ee r587867a  
    219219                if (!is_path(prefix) && cs->is_command) {
    220220                        cs->path_list[0] = malloc(sizeof(char) * PATH_MAX);
     221                        if (cs->path_list[0] == NULL) {
     222                                retval = ENOMEM;
     223                                goto error;
     224                        }
     225
    221226                        int ret = snprintf(cs->path_list[0], PATH_MAX, "%s/%s", search_dir[0], dirname);
    222227                        if (ret < 0 || ret >= PATH_MAX) {
     
    228233                }
    229234
     235                free(prefix);
    230236                cs->path_list[1] = NULL;
    231237                /*
Note: See TracChangeset for help on using the changeset viewer.