refactor: start to standardize on gchar

Make get_random_string() return a gchar*.

This is part of the effort to migrate string declarations and
allocations from char to gchar, replacing standard C allocators
(malloc/calloc/strdup) with their glib equivalents
(g_malloc/g_new0/g_strdup).

The primary goal is to prevent mismatched allocator bugs. While char and
gchar are binary compatible, mixing their respective deallocators is
dangerous:

* Freeing malloc'd memory with g_free() (or vice versa) can lead to
  memory corruption, double-frees, or crashes.
* This is seems to be the case especiall on non Linux platforms or when
  using hardened memory allocators where the GLib slice allocator or
  wrappers may differ from the system heap.

By standardizing on gchar, we ensure that our automatic cleanup macros
(like auto_gchar) always invoke the correct deallocator (g_free).
This commit is contained in:
Michael Vetter
2026-02-26 17:15:42 +01:00
parent e1fd2a1cf6
commit 8a36ca6d97
5 changed files with 8 additions and 8 deletions

View File

@@ -50,7 +50,7 @@
typedef struct aesgcm_download_t
{
char* id;
gchar* id;
char* url;
char* filename;
char* cmd_template;