[PATCH]libXt-1.0.8/src/TMstate.c avoid possible NULL reference

walter harms wharms at bfs.de
Fri Oct 22 10:38:27 PDT 2010


context->matches could become NULL, add check

re,
 wh

Signed-off-by: wharms at bfs.de


--- libXt-1.0.8/src/TMstate.c.org	2010-10-20 22:15:07.000000000 +0200
+++ libXt-1.0.8/src/TMstate.c	2010-10-20 22:35:35.000000000 +0200
@@ -720,10 +720,13 @@
 		  XtRealloc((char *)context->matches,
 			    context->maxMatches * sizeof(MatchPairRec));
 	    }
-	  context->matches[context->numMatches].isCycleStart = newState->isCycleStart;
-	  context->matches[context->numMatches].isCycleEnd = newState->isCycleEnd;
-	  context->matches[context->numMatches].typeIndex = newState->typeIndex;
-	  context->matches[context->numMatches++].modIndex = newState->modIndex;
+	  if ( context->matches )
+	    {
+	      context->matches[context->numMatches].isCycleStart = newState->isCycleStart;
+	      context->matches[context->numMatches].isCycleEnd = newState->isCycleEnd;
+	      context->matches[context->numMatches].typeIndex = newState->typeIndex;
+	      context->matches[context->numMatches++].modIndex = newState->modIndex;
+	    }
 	  *contextPtr = context;
       }
       UNLOCK_PROCESS;


More information about the xorg-devel mailing list