[glib/wip/carlosg/appinfo-environment-preconditions] gappinfo: Add precondition checks to GAppLaunchContext env methods
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/carlosg/appinfo-environment-preconditions] gappinfo: Add precondition checks to GAppLaunchContext env methods
- Date: Mon, 6 May 2019 11:12:49 +0000 (UTC)
commit 133ad1d390c785109494a79158c36c154f760180
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon May 6 12:50:36 2019 +0200
gappinfo: Add precondition checks to GAppLaunchContext env methods
Spotted in https://gitlab.gnome.org/GNOME/mutter/issues/586. Bad input
on GAppLaunchContext environment manipulation functions is caught by
inner code, but the warning is not seemingly related.
Add precondition checks to these functions so it's clear where does the
bad input come from.
gio/gappinfo.c | 9 +++++++++
1 file changed, 9 insertions(+)
---
diff --git a/gio/gappinfo.c b/gio/gappinfo.c
index 1fd0a7ad7..b2135e644 100644
--- a/gio/gappinfo.c
+++ b/gio/gappinfo.c
@@ -1204,6 +1204,10 @@ g_app_launch_context_setenv (GAppLaunchContext *context,
const char *variable,
const char *value)
{
+ g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
+ g_return_if_fail (variable != NULL);
+ g_return_if_fail (value != NULL);
+
if (!context->priv->envp)
context->priv->envp = g_get_environ ();
@@ -1225,6 +1229,9 @@ void
g_app_launch_context_unsetenv (GAppLaunchContext *context,
const char *variable)
{
+ g_return_if_fail (G_IS_APP_LAUNCH_CONTEXT (context));
+ g_return_if_fail (variable != NULL);
+
if (!context->priv->envp)
context->priv->envp = g_get_environ ();
@@ -1249,6 +1256,8 @@ g_app_launch_context_unsetenv (GAppLaunchContext *context,
char **
g_app_launch_context_get_environment (GAppLaunchContext *context)
{
+ g_return_val_if_fail (G_IS_APP_LAUNCH_CONTEXT (context), NULL);
+
if (!context->priv->envp)
context->priv->envp = g_get_environ ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]