Optionally return bytes received from http_file_get()

`http_dl->bytes_received` was already free'd when it was accessed inside
`aesgcm_file_get()`.

Change `http_file_get()` to optionally return the number of bytes received
so we know how much data we have to decrypt.

This fixes #1994

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2025-03-18 14:24:59 +01:00
parent 422f5fa6f9
commit 4405f33884
3 changed files with 15 additions and 3 deletions

View File

@@ -105,6 +105,7 @@ void*
http_file_get(void* userdata)
{
HTTPDownload* download = (HTTPDownload*)userdata;
ssize_t* ret = NULL;
char* err = NULL;
@@ -208,6 +209,10 @@ http_file_get(void* userdata)
"Downloading '%s': done\nSaved to '%s'",
download->url, download->filename);
win_mark_received(download->window, download->id);
if (download->return_bytes_received) {
ret = malloc(sizeof(*ret));
*ret = download->bytes_received;
}
}
}
@@ -241,7 +246,7 @@ out:
free(download->id);
free(download);
return NULL;
return ret;
}
void