Hi List,
while testing a static checker, i got warnings about a possible NULL access.
looking into the code i found that GetClassActions() may return NULL
causing table->signature to ask for trouble.

re,
 wh



Honor that GetClassActions() may return NULL.

Signed-off-by: Walter <[email protected]>


--- libXt-1.0.8/src/TMaction.c.org      2010-09-29 20:37:48.000000000 +0200
+++ libXt-1.0.8/src/TMaction.c  2010-09-29 20:39:56.000000000 +0200
@@ -807,10 +807,12 @@
     if (*num_actions_return) {
        list = *actions_return = (XtActionList)
            __XtMalloc(*num_actions_return * sizeof(XtActionsRec));
-       table = GetClassActions(widget_class);
-       for (i= (*num_actions_return); --i >= 0; list++, table++) {
-           list->string = XrmQuarkToString(table->signature);
-           list->proc = table->proc;
+       table = GetClassActions(widget_class);
+       if (table != NULL ) {
+               for (i= (*num_actions_return); --i >= 0; list++, table++) {
+                       list->string = XrmQuarkToString(table->signature);
+                       list->proc = table->proc;
+               }
        }
     }
     UNLOCK_PROCESS;
--- libXt-1.0.8/src/TMaction.c.org	2010-09-29 20:37:48.000000000 +0200
+++ libXt-1.0.8/src/TMaction.c	2010-09-29 20:39:56.000000000 +0200
@@ -807,10 +807,12 @@
     if (*num_actions_return) {
 	list = *actions_return = (XtActionList)
 	    __XtMalloc(*num_actions_return * sizeof(XtActionsRec));
-	table = GetClassActions(widget_class); /* FIXME: can be NULL */
-	for (i= (*num_actions_return); --i >= 0; list++, table++) {
-	    list->string = XrmQuarkToString(table->signature);
-	    list->proc = table->proc;
+	table = GetClassActions(widget_class); 
+	if (table != NULL ) {
+		for (i= (*num_actions_return); --i >= 0; list++, table++) {
+			list->string = XrmQuarkToString(table->signature);
+			list->proc = table->proc;
+		}
 	}
     }
     UNLOCK_PROCESS;
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to