diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-04-27 21:47:19 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-04-27 21:47:19 -0400 |
| commit | 586c2236573d156d8623eff00cef24ac688f88cb (patch) | |
| tree | e61729d0fb23d0ad80344e82f1d8bd366e5cc870 /widget.c | |
| parent | 40742d7d31a8c51f416b52a2a203c312bca8795e (diff) | |
| download | volute-586c2236573d156d8623eff00cef24ac688f88cb.zip | |
fix compressor-select widget names buffer allocation
Diffstat (limited to 'widget.c')
| -rw-r--r-- | widget.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -130,13 +130,19 @@ w_init_select_compressor(w_Select_Compressor *select, int n, const Compressor *c select->nfiltered = n; namesize = sizeof((*comps).brand) + sizeof((*comps).series) + sizeof((*comps).model) + 3; - select->names = malloc(n * namesize); + select->names = malloc(n * sizeof(*select->names)); if (select->names == NULL) { free(select->filtered); return 1; } /* TODO: parallelize. */ for (i = 0; i < n; i++) { + select->names[i] = malloc(namesize * sizeof(char)); + if (select->names[i] == NULL) { + free_arr((void **) select->names, i); + free(select->filtered); + return 1; + } snprintf(select->names[i], namesize, "%s %s %s", comps[i].brand, comps[i].series, comps[i].model); } @@ -152,7 +158,7 @@ w_init_select_compressor(w_Select_Compressor *select, int n, const Compressor *c void w_free_select_compressor(w_Select_Compressor *select) { free(select->filtered); - free(select->names); + free_arr((void **) select->names, select->n); } int |