From fb8fbafc0187e657049a85eb722bf55da6808169 Mon Sep 17 00:00:00 2001 From: Liviu Chircu Date: Wed, 17 Nov 2021 14:54:20 +0200 Subject: [PATCH] rest_client: Remove extra check Since "size_t" is an unsigned integer type, the RHS multiplication result cannot be negative unless an overflow occurs when assigning to LHS. So we change the type of "len" to unsigned as well, to prevent this corner-case. --- modules/rest_client/rest_cb.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/rest_client/rest_cb.c b/modules/rest_client/rest_cb.c index 53fc46f16ea..17b6e56426e 100644 --- a/modules/rest_client/rest_cb.c +++ b/modules/rest_client/rest_cb.c @@ -37,7 +37,7 @@ */ size_t write_func(char *ptr, size_t size, size_t nmemb, void *body) { - int len = size * nmemb; + unsigned int len = size * nmemb; str *buff = (str *)body; #ifdef EXTRA_DEBUG @@ -47,9 +47,6 @@ size_t write_func(char *ptr, size_t size, size_t nmemb, void *body) if (len == 0) return 0; - if (len < 0) - len = strlen(ptr); - buff->s = pkg_realloc(buff->s, buff->len + len + 1); if (!buff->s) { buff->len = 0;