mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:41:40 +03:00
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:
parent
4b85e489a4
commit
869143b194
11 changed files with 276 additions and 272 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue