examples: fix more potential resource leaks, and more

Also:
- delete dead code.
- sync `http2-download.c` and `http2-upload.c` sources.
- simplessl: fix constant expression.
- simplessl: avoid `expression is constant` VS2010 warning, drop pragma.
- replace large stack buffers with dynamic allocation.
- http2-download: fix to fill transfer number.

Some of these were pointed out by TIOBE scanner via Coverity 2025.3.0.

Closes #19292
This commit is contained in:
Viktor Szakats 2025-10-31 04:22:42 +01:00
parent 4b85e489a4
commit 869143b194
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
11 changed files with 276 additions and 272 deletions

View file

@ -72,6 +72,7 @@ static size_t payload_source(char *ptr, size_t size, size_t nmemb, void *userp)
struct upload_status *upload_ctx = (struct upload_status *)userp;
const char *data;
size_t room = size * nmemb;
size_t len;
if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
return 0;
@ -79,17 +80,13 @@ static size_t payload_source(char *ptr, size_t size, size_t nmemb, void *userp)
data = &payload_text[upload_ctx->bytes_read];
if(data) {
size_t len = strlen(data);
if(room < len)
len = room;
memcpy(ptr, data, len);
upload_ctx->bytes_read += len;
len = strlen(data);
if(room < len)
len = room;
memcpy(ptr, data, len);
upload_ctx->bytes_read += len;
return len;
}
return 0;
return len;
}
int main(void)