mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 15:33:39 +02:00
gutils: avoid race setting prgname from g_option_context_parse()/g_application_run()
g_option_context_parse()/g_application_run()/g_test_init() for convenience also call g_set_prgname(), when the prgname is unset at this point. This was racy. Fix the race by using an atomic compare-and-exchange and only reset the value, if it is unset still.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "gioenumtypes.h"
|
||||
#include "gioenums.h"
|
||||
#include "gfile.h"
|
||||
#include "glib-private.h"
|
||||
|
||||
#include "glibintl.h"
|
||||
#include "gmarshal-internal.h"
|
||||
@@ -2526,7 +2527,7 @@ g_application_run (GApplication *application,
|
||||
gchar *prgname;
|
||||
|
||||
prgname = g_path_get_basename (argv[0]);
|
||||
g_set_prgname (prgname);
|
||||
GLIB_PRIVATE_CALL (g_set_prgname_once) (prgname);
|
||||
g_free (prgname);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user