Skip to content

Commit adde058

Browse files
committed
resource: fix memory leaks in resource moodule
Problem: The resource module leaks a struct rlist and an R object when loading R from configuration. Free the intermediate rlist in convert_R_conf(), and the "R_from_config" after it is added to the inventory.
1 parent 7879439 commit adde058

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/modules/resource/inventory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ static int convert_R_conf (flux_t *h, json_t *conf_R, json_t **Rp)
280280
errno = ENOMEM;
281281
goto error;
282282
}
283+
rlist_destroy (rl);
283284
*Rp = R;
284285
return 0;
285286
error:

src/modules/resource/resource.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ int mod_main (flux_t *h, int argc, char **argv)
437437
}
438438
if (!(ctx->inventory = inventory_create (ctx, R_from_config)))
439439
goto error;
440+
/* Done with R_from_config now, so free it.
441+
*/
442+
json_decref (R_from_config);
440443
if (!(ctx->topology = topo_create (ctx, noverify, norestrict)))
441444
goto error;
442445
if (!(ctx->monitor = monitor_create (ctx, monitor_force_up)))

0 commit comments

Comments
 (0)