diff options
author | dgp@users.sourceforge.net <dgp> | 2015-06-03 12:26:38 (GMT) |
---|---|---|
committer | dgp@users.sourceforge.net <dgp> | 2015-06-03 12:26:38 (GMT) |
commit | 23a496d954de0ceaabbf92d01e4ab3cd32f4e8b9 (patch) | |
tree | 9107484dfcc509b829cbfc5bfccd0b339702ebe8 /generic/tclExecute.c | |
parent | e4f2fbcedb760b8fa338782579072f330cac432b (diff) | |
download | tcl-23a496d954de0ceaabbf92d01e4ab3cd32f4e8b9.zip tcl-23a496d954de0ceaabbf92d01e4ab3cd32f4e8b9.tar.gz tcl-23a496d954de0ceaabbf92d01e4ab3cd32f4e8b9.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/tclExecute.c')
-rw-r--r-- | generic/tclExecute.c | 14 |
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); } |