Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1743f8e in mainline


Ignore:
Timestamp:
2020-03-24T22:12:22Z (4 months ago)
Author:
Manuele Conti <manuele.conti@…>
Parents:
44dde42
Message:

Avoid memory leak in add_platform_fun return with ENOMEM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/root/root/root.c

    r44dde42 r1743f8e  
    144144
    145145        /* Null-terminate string. */
    146         platform = realloc(platform, platform_size + 1);
    147         if (platform == NULL) {
     146        char *tmp = realloc(platform, platform_size + 1);
     147        if (tmp == NULL) {
    148148                ddf_msg(LVL_ERROR, "Memory allocation failed.");
    149                 return ENOMEM;
    150         }
    151 
     149                free(platform);
     150                return ENOMEM;
     151        }
     152        platform = tmp;
    152153        platform[platform_size] = '\0';
    153154
Note: See TracChangeset for help on using the changeset viewer.