diff options
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -542,10 +542,12 @@ static void traversestrongtable (global_State *g, Table *h) { | |||
542 | static lu_mem traversetable (global_State *g, Table *h) { | 542 | static lu_mem traversetable (global_State *g, Table *h) { |
543 | const char *weakkey, *weakvalue; | 543 | const char *weakkey, *weakvalue; |
544 | const TValue *mode = gfasttm(g, h->metatable, TM_MODE); | 544 | const TValue *mode = gfasttm(g, h->metatable, TM_MODE); |
545 | TString *smode; | ||
545 | markobjectN(g, h->metatable); | 546 | markobjectN(g, h->metatable); |
546 | if (mode && ttisstring(mode) && /* is there a weak mode? */ | 547 | if (mode && ttisshrstring(mode) && /* is there a weak mode? */ |
547 | (cast_void(weakkey = strchr(svalue(mode), 'k')), | 548 | (cast_void(smode = tsvalue(mode)), |
548 | cast_void(weakvalue = strchr(svalue(mode), 'v')), | 549 | cast_void(weakkey = strchr(getshrstr(smode), 'k')), |
550 | cast_void(weakvalue = strchr(getshrstr(smode), 'v')), | ||
549 | (weakkey || weakvalue))) { /* is really weak? */ | 551 | (weakkey || weakvalue))) { /* is really weak? */ |
550 | if (!weakkey) /* strong keys? */ | 552 | if (!weakkey) /* strong keys? */ |
551 | traverseweakvalue(g, h); | 553 | traverseweakvalue(g, h); |