summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmaan Bhojwani <me@armaanb.net>2021-05-09 16:03:18 -0400
committerArmaan Bhojwani <me@armaanb.net>2021-05-09 16:03:18 -0400
commit504a7161d0c5b7d96993125badb80bdfe4669057 (patch)
tree2db81f4496c5aa3002988d256260d8b3e47c7113
parentb658d44c5a515751912b7af7cbddabc93592c2b9 (diff)
downloadmmenu-504a7161d0c5b7d96993125badb80bdfe4669057.tar.gz
Patch leaks
-rw-r--r--mmenu.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/mmenu.c b/mmenu.c
index 08f3d06..4e4283c 100644
--- a/mmenu.c
+++ b/mmenu.c
@@ -101,6 +101,8 @@ getmenu(char *date)
if (c == '>') intag = false;
}
+ free(chunk.memory);
+
// Strip empty newlines
char *nl = (char *) calloc(1, sizeof(char));
if (!nl) memfail();
@@ -116,8 +118,8 @@ getmenu(char *date)
strncat(nl, next, 2);
}
}
- free(outp);
+ free(outp);
return nl;
}
@@ -128,7 +130,10 @@ dayback(Widget unused, XtPointer client_data, XtPointer call_data)
Widget disp = (Widget) client_data;
XmListCallbackStruct *list_cbs = (XmListCallbackStruct *) call_data;
char *nl = getmenu(days[list_cbs->item_position - 1]);
- XmTextReplace((Widget) disp, 0, strlen(XmTextGetString(disp)), nl);
+ char *oldtext = XmTextGetString(disp) ;
+ XmTextReplace((Widget) disp, 0, strlen(oldtext), nl);
+ free(nl);
+ free(oldtext);
}
// Convert an array of string to an array of compound strings
@@ -165,7 +170,8 @@ main(int argc, char *argv[])
// Create text widget to display menu
n = 0;
- XtSetArg(args[n], XmNvalue, getmenu("")); n++;
+ char *nl = getmenu("");
+ XtSetArg(args[n], XmNvalue, nl); n++;
XtSetArg(args[n], XmNeditable, False); n++;
XtSetArg(args[n], XmNcolumns, 80); n++;
XtSetArg(args[n], XmNrows, 20); n++;
@@ -173,6 +179,7 @@ main(int argc, char *argv[])
XtSetArg(args[n], XmNcursorPositionVisible, False); n++;
disp = XmCreateScrolledText(rowcol, "text", args, n);
XtManageChild(disp);
+ free(nl);
// Create day selector
strs = ArgvToXmStringTable (XtNumber(days), days);