[PATCH libXt] Fix possible NULL access
walter harms
wharms at bfs.de
Tue Oct 26 04:43:51 PDT 2010
Fix possible NULL access
Signed-off-by: walter harms <wharms at bfs.de>
---
src/Resources.c | 3 +++
src/TMparse.c | 18 ++++++++++++++----
src/TMstate.c | 11 +++++++----
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/Resources.c b/src/Resources.c
index 1cb37d4..9230169 100644
--- a/src/Resources.c
+++ b/src/Resources.c
@@ -967,8 +967,11 @@ static XtCacheRef *GetResources(
if (cache_ptr && *cache_ptr)
cache_ptr++;
} else {
+ // value.addr can be NULL see: !already_copied
+ if (value.addr)
*((XtTranslations *)&widget->core.tm.current_state) =
*((XtTranslations *)value.addr);
+
}
}
}
diff --git a/src/TMparse.c b/src/TMparse.c
index 5fddb82..5930187 100644
--- a/src/TMparse.c
+++ b/src/TMparse.c
@@ -1288,10 +1288,15 @@ static void RepeatDownPlus(
*event = timerEventRec;
}
-
+ /*
+ if reps==0 -> lastDownEvent == NULL
+ */
event->next = lastDownEvent;
*eventP = event;
- *actionsP = &lastDownEvent->actions;
+ if (lastDownEvent)
+ *actionsP = &lastDownEvent->actions;
+ else
+ *actionsP = NULL ;
}
static void RepeatUp(
@@ -1395,10 +1400,15 @@ static void RepeatUpPlus(
*event = *downEvent;
}
-
+ /*
+ if reps==0 -> lastUpEvent == NULL
+ */
event->next = lastUpEvent;
*eventP = event;
- *actionsP = &lastUpEvent->actions;
+ if (lastUpEvent)
+ *actionsP = &lastUpEvent->actions;
+ else
+ *actionsP = NULL ;
}
static void RepeatOther(
diff --git a/src/TMstate.c b/src/TMstate.c
index 4a634b4..843292c 100644
--- a/src/TMstate.c
+++ b/src/TMstate.c
@@ -717,10 +717,13 @@ static void PushContext(
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;
--
1.6.0.2
More information about the xorg
mailing list