diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-06-21 22:19:09 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-06-21 22:37:30 +1000 |
commit | 26b7dc6cfe26e29f19301da17ac8677263c14c3b (patch) | |
tree | 6b3ef228dadbd747107e244322de5a4445f54512 /jim.c | |
parent | fbc998db178da5c462e164b63da128a7d7412e37 (diff) | |
download | jimtcl-26b7dc6cfe26e29f19301da17ac8677263c14c3b.zip jimtcl-26b7dc6cfe26e29f19301da17ac8677263c14c3b.tar.gz jimtcl-26b7dc6cfe26e29f19301da17ac8677263c14c3b.tar.bz2 |
Fix crash on dup of object with script rep
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.c')
-rw-r--r-- | jim.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -136,6 +136,8 @@ static const Jim_HashTableType JimVariablesHashTableType; /* Fast access to the int (wide) value of an object which is known to be of int type */ #define JimWideValue(objPtr) (objPtr)->internalRep.wideValue +#define JimObjTypeName(O) (objPtr->typePtr ? objPtr->typePtr->name : "none") + static int utf8_tounicode_case(const char *s, int *uc, int upper) { int l = utf8_tounicode(s, uc); @@ -2153,17 +2155,17 @@ Jim_Obj *Jim_DuplicateObj(Jim_Interp *interp, Jim_Obj *objPtr) else { Jim_InitStringRep(dupPtr, objPtr->bytes, objPtr->length); } + + /* By default, the new object has the same type as the old object */ + dupPtr->typePtr = objPtr->typePtr; if (objPtr->typePtr != NULL) { if (objPtr->typePtr->dupIntRepProc == NULL) { dupPtr->internalRep = objPtr->internalRep; } else { + /* The dup proc may set a different type, e.g. NULL */ objPtr->typePtr->dupIntRepProc(interp, objPtr, dupPtr); } - dupPtr->typePtr = objPtr->typePtr; - } - else { - dupPtr->typePtr = NULL; } return dupPtr; } |