[PATCH 08/15] newt: fix mem leak on error path
fix both show_multiselect_window and show_select_window.
---
packages/cdebconf/src/modules/frontend/newt/newt.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/packages/cdebconf/src/modules/frontend/newt/newt.c b/packages/cdebconf/src/modules/frontend/newt/newt.c
index b2b32be..69b1221 100644
--- a/packages/cdebconf/src/modules/frontend/newt/newt.c
+++ b/packages/cdebconf/src/modules/frontend/newt/newt.c
@@ -586,13 +586,17 @@ show_multiselect_window(struct frontend *obj, struct question *q, int show_ext_d
win_width = width-7;
strtruncate(obj->title, win_width-9);
count = strgetargc(q_get_choices_vals(obj, q));
- if (count <= 0)
+ if (count <= 0) {
+ free(full_description);
return DC_NOTOK;
+ }
choices = malloc(sizeof(char *) * count);
choices_trans = malloc(sizeof(char *) * count);
tindex = malloc(sizeof(int) * count);
- if (strchoicesplitsort(q_get_choices_vals(obj, q), q_get_choices(obj, q), indices, choices, choices_trans, tindex, count) != count)
+ if (strchoicesplitsort(q_get_choices_vals(obj, q), q_get_choices(obj, q), indices, choices, choices_trans, tindex, count) != count) {
+ free(full_description);
return DC_NOTOK;
+ }
if (obj->methods.can_align(obj, q)) {
stralign(choices_trans, count);
@@ -748,13 +752,17 @@ show_select_window(struct frontend *obj, struct question *q, int show_ext_desc)
win_width = width-7;
strtruncate(obj->title, win_width-9);
count = strgetargc(q_get_choices_vals(obj, q));
- if (count <= 0)
+ if (count <= 0) {
+ free(full_description);
return DC_NOTOK;
+ }
choices = malloc(sizeof(char *) * count);
choices_trans = malloc(sizeof(char *) * count);
tindex = malloc(sizeof(int) * count);
- if (strchoicesplitsort(q_get_choices_vals(obj, q), q_get_choices(obj, q), indices, choices, choices_trans, tindex, count) != count)
+ if (strchoicesplitsort(q_get_choices_vals(obj, q), q_get_choices(obj, q), indices, choices, choices_trans, tindex, count) != count) {
+ free(full_description);
return DC_NOTOK;
+ }
if (obj->methods.can_align(obj, q)) {
stralign(choices_trans, count);
--
1.7.2.3
Reply to: