Skip to content

Commit

Permalink
Fixed Issue laruence#97
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed May 15, 2014
1 parent 1097e40 commit e94ad22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
24 changes: 20 additions & 4 deletions configs/yaf_config_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ PHP_METHOD(yaf_config_ini, get) {
} else {
zval *properties;
char *entry, *seg, *pptr;
int seg_len;
long lval;
double dval;

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

Expand All @@ -709,19 +712,32 @@ PHP_METHOD(yaf_config_ini, get) {
entry = estrndup(name, len);
if ((seg = php_strtok_r(entry, ".", &pptr))) {
while (seg) {
if (zend_hash_find(Z_ARRVAL_P(properties), seg, strlen(seg) + 1, (void **) &ppzval) == FAILURE) {
efree(entry);
RETURN_NULL();
seg_len = strlen(seg);
if (is_numeric_string(seg, seg_len, &lval, &dval, 0) != IS_LONG) {
if (zend_hash_find(Z_ARRVAL_P(properties), seg, seg_len + 1, (void **) &ppzval) == FAILURE) {
efree(entry);
RETURN_NULL();
}
} else {
if (zend_hash_index_find(Z_ARRVAL_P(properties), lval, (void **) &ppzval) == FAILURE) {
efree(entry);
RETURN_NULL();
}
}

properties = *ppzval;
seg = php_strtok_r(NULL, ".", &pptr);
}
} else {
} else if (is_numeric_string(name, len, &lval, &dval, 0) != IS_LONG) {
if (zend_hash_find(Z_ARRVAL_P(properties), name, len + 1, (void **)&ppzval) == FAILURE) {
efree(entry);
RETURN_NULL();
}
} else {
if (zend_hash_index_find(Z_ARRVAL_P(properties), lval, (void **) &ppzval) == FAILURE) {
efree(entry);
RETURN_NULL();
}
}

efree(entry);
Expand Down
12 changes: 10 additions & 2 deletions configs/yaf_config_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,20 @@ PHP_METHOD(yaf_config_simple, get) {
} else {
zval *properties;
HashTable *hash;
long lval;
double dval;

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

if (zend_hash_find(hash, name, len + 1, (void **) &ppzval) == FAILURE) {
RETURN_FALSE;
if (is_numeric_string(name, len, &lval, &dval, 0) != IS_LONG) {
if (zend_hash_find(hash, name, len + 1, (void **) &ppzval) == FAILURE) {
RETURN_FALSE;
}
} else {
if (zend_hash_index_find(hash, lval, (void **) &ppzval) == FAILURE) {
RETURN_FALSE;
}
}

if (Z_TYPE_PP(ppzval) == IS_ARRAY) {
Expand Down

0 comments on commit e94ad22

Please sign in to comment.