Skip to content

Commit e94ad22

Browse files
committed
Fixed Issue laruence#97
1 parent 1097e40 commit e94ad22

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

configs/yaf_config_ini.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ PHP_METHOD(yaf_config_ini, get) {
699699
} else {
700700
zval *properties;
701701
char *entry, *seg, *pptr;
702+
int seg_len;
703+
long lval;
704+
double dval;
702705

703706
properties = zend_read_property(yaf_config_ini_ce, getThis(), ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC);
704707

@@ -709,19 +712,32 @@ PHP_METHOD(yaf_config_ini, get) {
709712
entry = estrndup(name, len);
710713
if ((seg = php_strtok_r(entry, ".", &pptr))) {
711714
while (seg) {
712-
if (zend_hash_find(Z_ARRVAL_P(properties), seg, strlen(seg) + 1, (void **) &ppzval) == FAILURE) {
713-
efree(entry);
714-
RETURN_NULL();
715+
seg_len = strlen(seg);
716+
if (is_numeric_string(seg, seg_len, &lval, &dval, 0) != IS_LONG) {
717+
if (zend_hash_find(Z_ARRVAL_P(properties), seg, seg_len + 1, (void **) &ppzval) == FAILURE) {
718+
efree(entry);
719+
RETURN_NULL();
720+
}
721+
} else {
722+
if (zend_hash_index_find(Z_ARRVAL_P(properties), lval, (void **) &ppzval) == FAILURE) {
723+
efree(entry);
724+
RETURN_NULL();
725+
}
715726
}
716727

717728
properties = *ppzval;
718729
seg = php_strtok_r(NULL, ".", &pptr);
719730
}
720-
} else {
731+
} else if (is_numeric_string(name, len, &lval, &dval, 0) != IS_LONG) {
721732
if (zend_hash_find(Z_ARRVAL_P(properties), name, len + 1, (void **)&ppzval) == FAILURE) {
722733
efree(entry);
723734
RETURN_NULL();
724735
}
736+
} else {
737+
if (zend_hash_index_find(Z_ARRVAL_P(properties), lval, (void **) &ppzval) == FAILURE) {
738+
efree(entry);
739+
RETURN_NULL();
740+
}
725741
}
726742

727743
efree(entry);

configs/yaf_config_simple.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,20 @@ PHP_METHOD(yaf_config_simple, get) {
141141
} else {
142142
zval *properties;
143143
HashTable *hash;
144+
long lval;
145+
double dval;
144146

145147
properties = zend_read_property(yaf_config_simple_ce, getThis(), ZEND_STRL(YAF_CONFIG_PROPERT_NAME), 1 TSRMLS_CC);
146148
hash = Z_ARRVAL_P(properties);
147149

148-
if (zend_hash_find(hash, name, len + 1, (void **) &ppzval) == FAILURE) {
149-
RETURN_FALSE;
150+
if (is_numeric_string(name, len, &lval, &dval, 0) != IS_LONG) {
151+
if (zend_hash_find(hash, name, len + 1, (void **) &ppzval) == FAILURE) {
152+
RETURN_FALSE;
153+
}
154+
} else {
155+
if (zend_hash_index_find(hash, lval, (void **) &ppzval) == FAILURE) {
156+
RETURN_FALSE;
157+
}
150158
}
151159

152160
if (Z_TYPE_PP(ppzval) == IS_ARRAY) {

0 commit comments

Comments
 (0)