summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2015-06-03 12:26:38 (GMT)
committerdgp <dgp@users.sourceforge.net>2015-06-03 12:26:38 (GMT)
commit0c2604871db8e162533e9729c9e5201334510785 (patch)
tree9107484dfcc509b829cbfc5bfccd0b339702ebe8 /generic
parent32461a99d3dc5741caf2f1c282ca57fe06220b79 (diff)
downloadtcl-0c2604871db8e162533e9729c9e5201334510785.zip
tcl-0c2604871db8e162533e9729c9e5201334510785.tar.gz
tcl-0c2604871db8e162533e9729c9e5201334510785.tar.bz2
[268b23df11] When GetSrcInfoForPc() returns NULL, make sure it also sets
the length to a non-positive value so nothing tries to read offsets from a NULL pointer.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclExecute.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 43c2b08..5957951 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -9995,10 +9995,8 @@ GetSrcInfoForPc(
int bestSrcLength = -1; /* Initialized to avoid compiler warning. */
int bestCmdIdx = -1;
- if ((pcOffset < 0) || (pcOffset >= codePtr->numCodeBytes)) {
- if (pcBeg != NULL) *pcBeg = NULL;
- return NULL;
- }
+ /* The pc must point within the bytecode */
+ assert ((pcOffset >= 0) && (pcOffset < codePtr->numCodeBytes));
/*
* Decode the code and source offset and length for each command. The
@@ -10083,10 +10081,6 @@ GetSrcInfoForPc(
*pcBeg = prev;
}
- if (bestDist == INT_MAX) {
- return NULL;
- }
-
if (lengthPtr != NULL) {
*lengthPtr = bestSrcLength;
}
@@ -10095,6 +10089,10 @@ GetSrcInfoForPc(
*cmdIdxPtr = bestCmdIdx;
}
+ if (bestDist == INT_MAX) {
+ return NULL;
+ }
+
return (codePtr->source + bestSrcOffset);
}