From 72dc506883848fdbbd0b4eae236231c5afd65b83 Mon Sep 17 00:00:00 2001 From: sebastid Date: Sat, 10 Jun 2006 19:26:25 +0000 Subject: [PATCH] Check if the array is larger than 0 Use malloc Make sure everything is freed SVN revision: 23362 --- legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c b/legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c index ef0503be1b..b6d5d965d3 100644 --- a/legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c +++ b/legacy/ecore/src/lib/ecore_x/ecore_x_icccm.c @@ -748,18 +748,30 @@ ecore_x_icccm_command_get(Ecore_X_Window win, int *argc, char ***argv) if (!XGetCommand(_ecore_x_disp, win, &v, &c)) return; + if (c < 1) + { + if (v) + XFreeStringList(v); + return; + } if (argc) *argc = c; if (argv) { - (*argv) = calloc(c, sizeof(char *)); + (*argv) = malloc(c * sizeof(char *)); if (!*argv) { - *argc = 0; + XFreeStringList(v); + if (argc) *argc = 0; return; } for (i = 0; i < c; i++) - (*argv)[i] = strdup(v[i]); + { + if (v[i]) + (*argv)[i] = strdup(v[i]); + else + (*argv)[i] = strdup(""); + } } XFreeStringList(v); }