From 64eadf160ace89847f7be3b867fd4220e19ee516 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 23 Feb 2018 07:58:11 +0100 Subject: [PATCH] fix cppcheck --- src/php_http_encoding.c | 2 +- src/php_http_info.c | 4 ++-- src/php_http_message.c | 2 +- src/php_http_message_body.c | 2 +- src/php_http_params.c | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/php_http_encoding.c b/src/php_http_encoding.c index 83d1794..f5d634a 100644 --- a/src/php_http_encoding.c +++ b/src/php_http_encoding.c @@ -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); diff --git a/src/php_http_info.c b/src/php_http_info.c index 5125a94..48da6bf 100644 --- a/src/php_http_info.c +++ b/src/php_http_info.c @@ -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)) { diff --git a/src/php_http_message.c b/src/php_http_message.c index 55225d3..49aa0f9 100644 --- a/src/php_http_message.c +++ b/src/php_http_message.c @@ -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)); diff --git a/src/php_http_message_body.c b/src/php_http_message_body.c index a6abfcd..526c233 100644 --- a/src/php_http_message_body.c +++ b/src/php_http_message_body.c @@ -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); diff --git a/src/php_http_params.c b/src/php_http_params.c index 5ba191f..b22769e 100644 --- a/src/php_http_params.c +++ b/src/php_http_params.c @@ -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) { -- 2.30.2