mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-30 19:06:38 +02:00
Avoid a use-after-free
Instead of pulling parent_window out of a copy of the environment and having it go bad when we free the copy, move the definition of GAppLaunchContextPrivate up and use the envp member without copying in. Pointed out by Cosimo Cecchi.
This commit is contained in:
@@ -90,6 +90,10 @@
|
||||
* different ideas of what a given URI means.
|
||||
*/
|
||||
|
||||
struct _GAppLaunchContextPrivate {
|
||||
char **envp;
|
||||
};
|
||||
|
||||
typedef GAppInfoIface GAppInfoInterface;
|
||||
G_DEFINE_INTERFACE (GAppInfo, g_app_info, G_TYPE_OBJECT)
|
||||
|
||||
@@ -683,13 +687,8 @@ launch_default_with_portal (const char *uri,
|
||||
if (session_bus == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (context)
|
||||
{
|
||||
char **env;
|
||||
env = g_app_launch_context_get_environment (context);
|
||||
parent_window = g_environ_getenv (env, "PARENT_WINDOW_ID");
|
||||
g_strfreev (env);
|
||||
}
|
||||
if (context && context->priv->envp)
|
||||
parent_window = g_environ_getenv (context->priv->envp, "PARENT_WINDOW_ID");
|
||||
|
||||
g_variant_builder_init (&opt_builder, G_VARIANT_TYPE_VARDICT);
|
||||
|
||||
@@ -841,10 +840,6 @@ enum {
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
struct _GAppLaunchContextPrivate {
|
||||
char **envp;
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GAppLaunchContext, g_app_launch_context, G_TYPE_OBJECT)
|
||||
|
Reference in New Issue
Block a user