Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: ecore-e16.c ecore-e16.h icccm.c memory.c Log Message: Fix handling of WM_COMMAND with bogus value. =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/ecore-e16.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- ecore-e16.c 9 Mar 2005 23:10:05 -0000 1.8 +++ ecore-e16.c 16 Mar 2005 19:16:45 -0000 1.9 @@ -183,10 +183,14 @@ /* * Get simple string list property + * + * If the property was successfully fetched the number of items stored in + * lst is returned, otherwise -1 is returned. + * Note: Return value 0 means that the property exists but has no elements. */ -char ** +int ecore_x_window_prop_string_list_get(Ecore_X_Window win, Ecore_X_Atom atom, - int *pnum) + char ***plst) { char **pstr = NULL; XTextProperty xtp; @@ -194,33 +198,38 @@ char **list; Status s; - *pnum = 0; + *plst = NULL; if (!XGetTextProperty(_ecore_x_disp, win, &xtp, atom)) - return NULL; + return -1; if (xtp.format == 8) { s = XmbTextPropertyToTextList(_ecore_x_disp, &xtp, &list, &items); - if ((s == Success) && (items > 0)) + if (s == Success) { - pstr = Emalloc(items * sizeof(char *)); - for (i = 0; i < items; i++) - pstr[i] = Estrdup(list[i]); - XFreeStringList(list); + if (items > 0) + { + pstr = Emalloc(items * sizeof(char *)); + for (i = 0; i < items; i++) + pstr[i] = Estrdup(list[i]); + } + if (list) + XFreeStringList(list); + goto done; } } - if (!pstr) - { - pstr = Emalloc(sizeof(char *)); - pstr[1] = Estrdup((char *)xtp.value); - items = 1; - } + /* Bad format or XmbTextPropertyToTextList failed - Now what? */ + pstr = Emalloc(sizeof(char *)); + pstr[0] = Estrdup((char *)xtp.value); + items = 1; + + done: XFree(xtp.value); - *pnum = items; - return pstr; + *plst = pstr; + return items; } #ifndef USE_ECORE_X =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/ecore-e16.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ecore-e16.h 6 Mar 2005 11:17:04 -0000 1.5 +++ ecore-e16.h 16 Mar 2005 19:16:45 -0000 1.6 @@ -266,9 +266,9 @@ void ecore_x_window_prop_string_list_set(Ecore_X_Window win, Ecore_X_Atom atom, char **lst, int num); -char **ecore_x_window_prop_string_list_get(Ecore_X_Window win, +int ecore_x_window_prop_string_list_get(Ecore_X_Window win, Ecore_X_Atom atom, - int *pnum); + char ***plst); void ecore_x_window_prop_xid_set(Ecore_X_Window win, Ecore_X_Atom atom, =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/icccm.c,v retrieving revision 1.90 retrieving revision 1.91 diff -u -3 -r1.90 -r1.91 --- icccm.c 12 Mar 2005 15:22:08 -0000 1.90 +++ icccm.c 16 Mar 2005 19:16:45 -0000 1.91 @@ -552,13 +552,13 @@ _EFREE(ewin->icccm.wm_command); - argv = ecore_x_window_prop_string_list_get(ewin->client.win, + argc = ecore_x_window_prop_string_list_get(ewin->client.win, ECORE_X_ATOM_WM_COMMAND, - &argc); - if (!argv && TryGroup(ewin)) - argv = ecore_x_window_prop_string_list_get(ewin->client.group, + &argv); + if ((argc < 0) && TryGroup(ewin)) + argc = ecore_x_window_prop_string_list_get(ewin->client.group, ECORE_X_ATOM_WM_COMMAND, - &argc); + &argv); ewin->icccm.wm_command = Estrdup(EstrlistEncodeEscaped(s, sizeof(s), argv, argc)); =================================================================== RCS file: /cvsroot/enlightenment/e16/e/src/memory.c,v retrieving revision 1.43 retrieving revision 1.44 diff -u -3 -r1.43 -r1.44 --- memory.c 12 Mar 2005 15:27:31 -0000 1.43 +++ memory.c 16 Mar 2005 19:16:46 -0000 1.44 @@ -146,6 +146,9 @@ p = lst[0]; for (i = 0; i < len - 2; i++) { + if (!p) /* A string list should not contain NULL items */ + break; + ch = *p++; switch (ch) { ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs