Skip to content

Commit c13db73

Browse files
committed
Use _ex versions of hash functions.
The non _ex versions cause a abort() when using: php: /home/derick/dev/php/php-src.git/Zend/zend_hash.c:2050: zend_hash_internal_pointer_reset_ex: Assertion `(&ht->nInternalPointer != pos || (ht)->gc.refcount == 1) || ((ht)->u.flags & (1<<6))' failed. Program received signal SIGABRT, Aborted. __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) backtrace assertion=assertion@entry=0x555556655a28 "(&ht->nInternalPointer != pos || (ht)->gc.refcount == 1) || ((ht)->u.flags & (1<<6))", file=file@entry=0x555556655840 "/home/derick/dev/php/php-src.git/Zend/zend_hash.c", line=line@entry=2050, function=function@entry=0x555556655f20 <__PRETTY_FUNCTION__.11898> "zend_hash_internal_pointer_reset_ex") at assert.c:92 file=0x555556655840 "/home/derick/dev/php/php-src.git/Zend/zend_hash.c", line=2050, function=0x555556655f20 <__PRETTY_FUNCTION__.11898> "zend_hash_internal_pointer_reset_ex") at assert.c:101 url=0x555556c043f0 "https://api.twitter.com/1.1/statuses/home_timeline.json?count=100&page=1&oauth_consumer_key=XXXXXXXXXXXXXXXXXXXXX&oauth_signature_method=HMAC-SHA1&oauth_nonce=XXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXX&oauth_ti"..., payload=0x7fffffffa370, http_method=0x555556c1c458 "GET", request_headers=0x555556c03bd0) at /home/derick/dev/php/pecl-oauth/oauth.c:880 request_params=0x7ffff38e9790, request_headers=0x0, init_oauth_args=0x0, fetch_flags=9) at /home/derick/dev/php/pecl-oauth/oauth.c:1578
1 parent 342b122 commit c13db73

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

oauth.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,18 +794,19 @@ static long make_req_streams(php_so_object *soo, const char *url, const smart_st
794794
}
795795

796796
if (request_headers) {
797+
HashPosition pos;
797798
zval *cur_val, zheaders;
798799
zend_string *cur_key;
799800
ulong num_key;
800801
smart_string sheaders = {0};
801802
int first = 1;
802803

803-
for (zend_hash_internal_pointer_reset(request_headers);
804-
(cur_val = zend_hash_get_current_data(request_headers)) != NULL;
805-
zend_hash_move_forward(request_headers)) {
804+
for (zend_hash_internal_pointer_reset_ex(request_headers, &pos);
805+
(cur_val = zend_hash_get_current_data_ex(request_headers, &pos)) != NULL;
806+
zend_hash_move_forward_ex(request_headers, &pos)) {
806807
/* check if a string based key is used */
807808
smart_string sheaderline = {0};
808-
switch (zend_hash_get_current_key(request_headers, &cur_key, &num_key)) {
809+
switch (zend_hash_get_current_key_ex(request_headers, &cur_key, &num_key, &pos)) {
809810
case HASH_KEY_IS_STRING:
810811
smart_string_appendl(&sheaderline, ZSTR_VAL(cur_key), ZSTR_LEN(cur_key));
811812
break;
@@ -876,16 +877,17 @@ static long make_req_streams(php_so_object *soo, const char *url, const smart_st
876877

877878
if (Z_TYPE(s->wrapperdata) != IS_UNDEF) {
878879
zval *tmp;
880+
HashPosition pos;
879881

880-
zend_hash_internal_pointer_reset(Z_ARRVAL(s->wrapperdata));
881-
while ((tmp = zend_hash_get_current_data(Z_ARRVAL(s->wrapperdata))) != NULL) {
882+
zend_hash_internal_pointer_reset_ex(Z_ARRVAL(s->wrapperdata), &pos);
883+
while ((tmp = zend_hash_get_current_data_ex(Z_ARRVAL(s->wrapperdata), &pos)) != NULL) {
882884
smart_string_appendl(&soo->headers_in, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
883885
smart_string_appends(&soo->headers_in, "\r\n");
884886
HTTP_RESPONSE_CODE(tmp);
885887
HTTP_RESPONSE_LOCATION(tmp);
886888
HTTP_RESPONSE_CAAS(tmp, "Content-Type: ", "content_type");
887889
HTTP_RESPONSE_CAAD(tmp, "Content-Length: ", "download_content_length");
888-
zend_hash_move_forward(Z_ARRVAL(s->wrapperdata));
890+
zend_hash_move_forward_ex(Z_ARRVAL(s->wrapperdata), &pos);
889891
}
890892
if (HTTP_IS_REDIRECT(response_code) && soo->last_location_header) {
891893
CAAS("redirect_url", soo->last_location_header);

0 commit comments

Comments
 (0)