Skip to content

Commit 17c6f41

Browse files
jdelongsgolemon
authored andcommitted
Fix a bug in register_variable
The second lvalAt line doesn't necessarily return the same array offset that the append call created if the nextKI wasn't in sync with the array size. I didn't entirely think through why the repro case hit this, but this version doesn't and is more correct. Reviewed By: @edwinsmith Differential Revision: D1249471
1 parent 26c5071 commit 17c6f41

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hphp/runtime/base/program-functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ void register_variable(Array& variables, char *name, const Variant& value,
285285
}
286286

287287
if (!index) {
288-
symtable->append(Array::Create());
288+
auto& val = symtable->lvalAt();
289+
val = Array::Create();
289290
gpc_elements.push_back(uninit_null());
290-
auto& val = symtable->lvalAt((int64_t)symtable->size() - 1);
291291
gpc_elements.back().assignRef(val);
292292
} else {
293293
String key(index, index_len, CopyString);

0 commit comments

Comments
 (0)