Fix more potential leaks in aesgcm_download

This commit is contained in:
Michael Vetter
2025-03-06 14:27:13 +01:00
parent 43bbb16e8e
commit b5f0cc0bd4
4 changed files with 46 additions and 23 deletions

View File

@@ -130,6 +130,36 @@ auto_free_char(char** str)
free(*str);
}
/**
* Closes the file descriptor.
*
* @param fd file descriptor handle. If NULL, no action is taken.
*/
void
auto_close_gfd(gint* fd)
{
if (fd == NULL)
return;
if (close(*fd) == EOF)
log_error(g_strerror(errno));
}
/**
* Closes file stream
*
* @param fd file descriptor handle opened with fopen. If NULL, no action is taken.
*/
void
auto_close_FILE(FILE** fd)
{
if (fd == NULL)
return;
if (fclose(*fd) == EOF)
log_error(g_strerror(errno));
}
static gboolean
_load_keyfile(prof_keyfile_t* keyfile)
{