Skip to content

Instantly share code, notes, and snippets.

@simonwelsh
Created December 5, 2013 19:57
Show Gist options
  • Save simonwelsh/7812789 to your computer and use it in GitHub Desktop.
Save simonwelsh/7812789 to your computer and use it in GitHub Desktop.
diff --git a/hphp/runtime/vm/member-operations.h b/hphp/runtime/vm/member-operations.h
index 806c6c6..fea0229 100644
--- a/hphp/runtime/vm/member-operations.h
+++ b/hphp/runtime/vm/member-operations.h
@@ -192,32 +192,35 @@
template <bool warn, KeyType keyType>
inline TypedValue* ElemArray(ArrayData* base, TypedValue* key) {
TypedValue* result;
if (keyType == KeyType::Any) {
DataType rtt = key->m_type;
if (rtt == KindOfInt64) {
result = ElemArrayRawKey(base, key->m_data.num);
} else if (IS_STRING_TYPE(rtt)) {
result = ElemArrayRawKey(base, key->m_data.pstr);
} else {
result = const_cast<TypedValue*>(ArrNR(base).asArray()
.rvalAtRef(cellAsCVarRef(*key))
.asTypedValue());
+ if (result->m_type == KindOfUninit) {
+ result = const_cast<TypedValue*>(init_null_variant.asTypedValue());
+ }
}
} else {
result = ElemArrayRawKey(base, keyAsRaw<keyType>(key));
}
if (UNLIKELY(result->m_type == KindOfUninit)) {
result = const_cast<TypedValue*>(init_null_variant.asTypedValue());
if (warn) {
TypedValue scratch;
initScratchKey<keyType>(scratch, key);
raise_notice(Strings::UNDEFINED_INDEX,
tvAsCVarRef(key).toString().data());
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment