check string options for NULL
[m6w6/ext-http] / php_http_env_response.c
index f9e8c4cb43ce7045679a3963810e5ac06270df9c..d13cde104a7acb9f8230613ff3704173fdfcb15f 100644 (file)
@@ -62,12 +62,14 @@ static void set_option(zval *options, const char *name_str, size_t name_len, int
 }
 static zval *get_option(zval *options, const char *name_str, size_t name_len)
 {
-       zval *val;
+       zval *val = NULL;
 
        if (Z_TYPE_P(options) == IS_OBJECT) {
                val = zend_read_property(Z_OBJCE_P(options), options, name_str, name_len, 0);
-       } else {
+       } else if (Z_TYPE_P(options) == IS_ARRAY) {
                val = zend_symtable_str_find(Z_ARRVAL_P(options), name_str, name_len);
+       } else {
+               abort();
        }
        if (val) {
                Z_TRY_ADDREF_P(val);
@@ -85,7 +87,7 @@ static php_http_message_body_t *get_body(zval *options)
 
                        body = body_obj->body;
                }
-               zval_ptr_dtor(zbody);
+               Z_TRY_DELREF_P(zbody);
        }
 
        return body;
@@ -101,7 +103,7 @@ static php_http_message_t *get_request(zval *options)
 
                        request = request_obj->message;
                }
-               zval_ptr_dtor(zrequest);
+               Z_TRY_DELREF_P(zrequest);
        }
 
        return request;
@@ -119,6 +121,7 @@ static void set_cookie(zval *options, zval *zcookie_new TSRMLS_DC)
                }
                array_init_size(zcookies_set, zend_hash_num_elements(&obj->list->cookies));
        } else {
+               Z_ADDREF_P(zcookies_set);
                SEPARATE_ZVAL(zcookies_set);
        }
 
@@ -465,7 +468,6 @@ static ZEND_RESULT_CODE php_http_env_response_send_head(php_http_env_response_t
                                zval *tmp = zoption;
                                SEPARATE_ZVAL(tmp);
                                convert_to_array(tmp);
-                               zval_ptr_dtor(zoption);
                                zoption = tmp;
                        }
 
@@ -502,7 +504,7 @@ static ZEND_RESULT_CODE php_http_env_response_send_head(php_http_env_response_t
                                                zend_ulong index = 0;
 
                                                zend_hash_internal_pointer_reset(result);
-                                               if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key_str, &index, NULL)) {
+                                               if (HASH_KEY_IS_STRING == zend_hash_get_current_key(result, &key_str, &index)) {
                                                        if (zend_string_equals_literal(key_str, "gzip")) {
                                                                if (!(r->content.encoder = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_deflate_ops(), PHP_HTTP_DEFLATE_TYPE_GZIP))) {
                                                                        ret = FAILURE;