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 83d17947790c106abfc8702f3ac975d8aa5b15ba..f5d634a105ac6a2dd046e679c57dafc72334920f 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 5125a94f2318917369f1d7699dba5ac0f59618e4..48da6bfe2170452f4aa3adb5d2a20d35dabc6ed4 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 55225d3173b3662dd347c9952baa1007d099865a..49aa0f94a1af971d81cef82042e806d0e323b825 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 a6abfcd0b5cf4c5a976ea7b0b1cee7754c3bdc24..526c233f18af4a3aebaabfcb1f7d4ba49f52063f 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 5ba191f161e4590b6a1d71deabb4c475433c63e3..b22769ef7531af5ac4dea2fc591deb618e0da77c 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) {