fix cppcheck
authorMichael Wallner <mike@php.net>
Fri, 23 Feb 2018 06:58:11 +0000 (07:58 +0100)
committerMichael Wallner <mike@php.net>
Fri, 23 Feb 2018 06:58:11 +0000 (07:58 +0100)
src/php_http_encoding.c
src/php_http_info.c
src/php_http_message.c
src/php_http_message_body.c
src/php_http_params.c

index 83d1794..f5d634a 100644 (file)
@@ -920,7 +920,7 @@ php_http_encoding_stream_object_t *php_http_encoding_stream_object_new_ex(zend_c
 
 zend_object *php_http_encoding_stream_object_clone(zval *object)
 {
-       php_http_encoding_stream_object_t *new_obj = NULL, *old_obj = PHP_HTTP_OBJ(NULL, object);
+       php_http_encoding_stream_object_t *new_obj, *old_obj = PHP_HTTP_OBJ(NULL, object);
        php_http_encoding_stream_t *cpy = php_http_encoding_stream_copy(old_obj->stream, NULL);
 
        new_obj = php_http_encoding_stream_object_new_ex(old_obj->zo.ce, cpy);
index 5125a94..48da6bf 100644 (file)
@@ -163,7 +163,7 @@ php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_head
                        PHP_HTTP_INFO(info).response.code = 0;
                }
                if (EXPECTED(status && end > status)) {
-                       while (' ' == *status) ++status;
+                       while (' ' == *status && end > status) ++status;
                        PHP_HTTP_INFO(info).response.status = estrndup(status, end - status);
                } else {
                        PHP_HTTP_INFO(info).response.status = NULL;
@@ -182,7 +182,7 @@ php_http_info_t *php_http_info_parse(php_http_info_t *info, const char *pre_head
 
                        PHP_HTTP_INFO(info).request.method = estrndup(pre_header, url_len);
 
-                       while (' ' == *url) ++url;
+                       while (' ' == *url && http > url) ++url;
                        while (' ' == *(http-1)) --http;
 
                        if (EXPECTED(http > url)) {
index 55225d3..49aa0f9 100644 (file)
@@ -858,7 +858,7 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce,
 
 zend_object *php_http_message_object_clone(zval *this_ptr)
 {
-       php_http_message_object_t *new_obj = NULL;
+       php_http_message_object_t *new_obj;
        php_http_message_object_t *old_obj = PHP_HTTP_OBJ(NULL, this_ptr);
 
        new_obj = php_http_message_object_new_ex(old_obj->zo.ce, php_http_message_copy(old_obj->message, NULL));
index a6abfcd..526c233 100644 (file)
@@ -579,7 +579,7 @@ php_http_message_body_object_t *php_http_message_body_object_new_ex(zend_class_e
 
 zend_object *php_http_message_body_object_clone(zval *object)
 {
-       php_http_message_body_object_t *new_obj = NULL;
+       php_http_message_body_object_t *new_obj;
        php_http_message_body_object_t *old_obj = PHP_HTTP_OBJ(NULL, object);
        php_http_message_body_t *body = php_http_message_body_copy(old_obj->body, NULL);
 
index 5ba191f..b22769e 100644 (file)
@@ -136,12 +136,11 @@ static inline void prepare_urlencoded(zval *zv)
 
 static void sanitize_dimension(zval *zv)
 {
-       zval arr, tmp, *cur = NULL;
+       zval arr, tmp, *cur = &arr;
        char *var = NULL, *ptr = Z_STRVAL_P(zv), *end = Z_STRVAL_P(zv) + Z_STRLEN_P(zv);
        long level = 0;
 
        array_init(&arr);
-       cur = &arr;
 
        while (ptr < end) {
                if (!var) {