Skip to content

Commit

Permalink
fix: memory leak in clib_package_new (#323)
Browse files Browse the repository at this point in the history
Direct leak of 32 byte(s) in 1 object(s) allocated from:
    0 malloc
    1 json_object_init clib/deps/parson/parson.c:291:42
    2 json_value_init_object clib/deps/parson/parson.c:1077:31
    3 parse_object_value clib/deps/parson/parson.c:580:32
    4 parse_value clib/deps/parson/parson.c:561:20
    5 parse_object_value clib/deps/parson/parson.c:600:21
    6 parse_value clib/deps/parson/parson.c:561:20
    7 json_parse_string clib/deps/parson/parson.c:910:12
    8 clib_package_new clib/src/common/clib-package.c:468:16
    9 clib_package_load_from_manifest clib/src/common/clib-package.c:259:9
  • Loading branch information
tyler92 authored Dec 18, 2024
1 parent 5f85b72 commit 1d505c8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/clib-package.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ clib_package_t *clib_package_new(const char *json, int verbose) {
for (unsigned int i = 0; i < json_array_get_count(flags); i++) {
char *flag = json_array_get_string_safe(flags, i);
if (flag) {
char *old_flags = pkg->flags;

if (!pkg->flags) {
pkg->flags = "";
}
Expand All @@ -521,6 +523,7 @@ clib_package_t *clib_package_new(const char *json, int verbose) {
goto cleanup;
}

free(old_flags);
free(flag);
}
}
Expand Down

0 comments on commit 1d505c8

Please sign in to comment.