From e61e3c24152fe0a236001726baa0c9537b704100 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 12 Jan 2018 18:58:22 +0100 Subject: Refactor to improve the scoping --- src/sp_var_value.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/sp_var_value.c') diff --git a/src/sp_var_value.c b/src/sp_var_value.c index 9a23ad9..c56c28f 100644 --- a/src/sp_var_value.c +++ b/src/sp_var_value.c @@ -92,19 +92,20 @@ static void *get_entry_hashtable(const HashTable *ht, const char *entry, static zval *get_array_value(zend_execute_data *ed, zval *zvalue, const sp_tree *tree) { - zval *idx_value, *ret = NULL; - char *idx = NULL; + zval *idx_value = get_value(ed, tree->idx, false); - idx_value = get_value(ed, tree->idx, false); if (!zvalue || !idx_value) { return NULL; } + if (Z_TYPE_P(zvalue) == IS_ARRAY) { - idx = sp_convert_to_string(idx_value); - ret = get_entry_hashtable(Z_ARRVAL_P(zvalue), idx, strlen(idx)); + char *idx = sp_convert_to_string(idx_value); + zval *ret = get_entry_hashtable(Z_ARRVAL_P(zvalue), idx, strlen(idx)); efree(idx); + return ret; } - return ret; + + return NULL; } static zval *get_object_property(zend_execute_data *ed, zval *object, -- cgit v1.3