Slightly improve http_download related allocations.
* use `calloc()` to allocate zero-initialized structs. * order the allocation of members by their declaration. * order the freeing of members in reverse order. * move init of `silent` flag in plugin case. * fix double free of `tmpname` in `aesgcm_file_get()`. * make some functions static. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
@@ -77,7 +77,7 @@ aesgcm_file_get(void* userdata)
|
||||
|
||||
// Create a temporary file used for storing the ciphertext that is to be
|
||||
// retrieved from the https:// URL.
|
||||
auto_gchar char* tmpname = NULL;
|
||||
auto_gchar gchar* tmpname = NULL;
|
||||
auto_gfd gint tmpfd = 0;
|
||||
if ((tmpfd = g_file_open_tmp("profanity.XXXXXX", &tmpname, NULL)) == -1) {
|
||||
http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->id,
|
||||
@@ -101,7 +101,7 @@ aesgcm_file_get(void* userdata)
|
||||
|
||||
// We wrap the HTTPDownload tool and use it for retrieving the ciphertext
|
||||
// and storing it in the temporary file previously opened.
|
||||
HTTPDownload* http_dl = malloc(sizeof(HTTPDownload));
|
||||
HTTPDownload* http_dl = calloc(1, sizeof(HTTPDownload));
|
||||
http_dl->window = aesgcm_dl->window;
|
||||
http_dl->worker = aesgcm_dl->worker;
|
||||
http_dl->id = strdup(aesgcm_dl->id);
|
||||
@@ -128,7 +128,6 @@ aesgcm_file_get(void* userdata)
|
||||
http_dl->bytes_received, fragment);
|
||||
|
||||
remove(tmpname);
|
||||
g_free(tmpname);
|
||||
|
||||
if (crypt_res != GPG_ERR_NO_ERROR) {
|
||||
http_print_transfer_update(aesgcm_dl->window, aesgcm_dl->id,
|
||||
|
||||
Reference in New Issue
Block a user