summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-01-28 14:59:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-01-28 14:59:00 (GMT)
commitbb38bb643d51cb226998de0ceb24ec6dec3633a7 (patch)
tree72e07b319a1edc4214219dd25059a96c1374a66a /generic
parent016004b79f96bcd0936415f3b901fd79fea50025 (diff)
parent933584b14430d2c9df09702eb344ff261bd40776 (diff)
downloadtcl-bb38bb643d51cb226998de0ceb24ec6dec3633a7.zip
tcl-bb38bb643d51cb226998de0ceb24ec6dec3633a7.tar.gz
tcl-bb38bb643d51cb226998de0ceb24ec6dec3633a7.tar.bz2
Allow indexPtr to be (int *)NULL
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIndexObj.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c
index cb376f3..cd15345 100644
--- a/generic/tclIndexObj.c
+++ b/generic/tclIndexObj.c
@@ -235,11 +235,12 @@ GetIndexFromObjList(
* Results:
* If the value of objPtr is identical to or a unique abbreviation for
* one of the entries in tablePtr, then the return value is TCL_OK and
- * the index of the matching entry is stored at *indexPtr. If there isn't
- * a proper match, then TCL_ERROR is returned and an error message is
- * left in interp's result (unless interp is NULL). The msg argument is
- * used in the error message; for example, if msg has the value "option"
- * then the error message will say something like 'bad option "foo": must
+ * the index of the matching entry is stored at *indexPtr
+ * (unless indexPtr is NULL). If there isn't a proper match, then
+ * TCL_ERROR is returned and an error message is left in interp's
+ * result (unless interp is NULL). The msg argument is used in the
+ * error message; for example, if msg has the value "option" then
+ * the error message will say something like 'bad option "foo": must
* be ...'
*
* Side effects:
@@ -367,22 +368,24 @@ Tcl_GetIndexFromObjStruct(
}
uncachedDone:
- if ((flags>>8) & (int)~sizeof(int)) {
- if ((flags>>8) == sizeof(uint64_t)) {
- *(uint64_t *)indexPtr = index;
- return TCL_OK;
- } else if ((flags>>8) == sizeof(uint32_t)) {
- *(uint32_t *)indexPtr = index;
- return TCL_OK;
- } else if ((flags>>8) == sizeof(uint16_t)) {
- *(uint16_t *)indexPtr = index;
- return TCL_OK;
- } else if ((flags>>8) == sizeof(uint8_t)) {
- *(uint8_t *)indexPtr = index;
- return TCL_OK;
+ if (indexPtr != NULL) {
+ if ((flags>>8) & (int)~sizeof(int)) {
+ if ((flags>>8) == sizeof(uint64_t)) {
+ *(uint64_t *)indexPtr = index;
+ return TCL_OK;
+ } else if ((flags>>8) == sizeof(uint32_t)) {
+ *(uint32_t *)indexPtr = index;
+ return TCL_OK;
+ } else if ((flags>>8) == sizeof(uint16_t)) {
+ *(uint16_t *)indexPtr = index;
+ return TCL_OK;
+ } else if ((flags>>8) == sizeof(uint8_t)) {
+ *(uint8_t *)indexPtr = index;
+ return TCL_OK;
+ }
}
+ *(int *)indexPtr = index;
}
- *(int *)indexPtr = index;
return TCL_OK;
error: