[glib/glib-2-64: 1/2] GWin32RegistryKey: Move assertions
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-64: 1/2] GWin32RegistryKey: Move assertions
- Date: Thu, 2 Jul 2020 14:30:32 +0000 (UTC)
commit 98570e2d697102ebe3890e1c43d29567a9708ab9
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Thu Jun 4 18:06:36 2020 +0000
GWin32RegistryKey: Move assertions
While these assertions look right at the first glance,
they actually crash the program. That's because GObject
insists on initializing all construct-only properties
to their default values, which results in
g_win32_registry_key_set_property() being called multiple
times with NULL string, once for each unset property.
If "path" is actually set by the caller, a subsequent
call to set "path-utf16" to NULL will fail an assertion,
since absolute_path is already non-NULL.
With assertions moved the set-to-NULL calls bail out before
an assertion is made.
gio/gwin32registrykey.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/gio/gwin32registrykey.c b/gio/gwin32registrykey.c
index c19fede4e..aa7819294 100644
--- a/gio/gwin32registrykey.c
+++ b/gio/gwin32registrykey.c
@@ -2334,8 +2334,6 @@ g_win32_registry_key_set_property (GObject *object,
switch (prop_id)
{
case PROP_PATH:
- g_assert (priv->absolute_path_w == NULL);
- g_assert (priv->absolute_path == NULL);
path = g_value_get_string (value);
if (path == NULL)
@@ -2346,20 +2344,21 @@ g_win32_registry_key_set_property (GObject *object,
if (path_w == NULL)
break;
- g_free (priv->absolute_path_w);
- g_free (priv->absolute_path);
+ /* Construct only */
+ g_assert (priv->absolute_path_w == NULL);
+ g_assert (priv->absolute_path == NULL);
priv->absolute_path_w = path_w;
priv->absolute_path = g_value_dup_string (value);
break;
case PROP_PATH_UTF16:
- g_assert (priv->absolute_path_w == NULL);
- g_assert (priv->absolute_path == NULL);
path_w = (gunichar2 *) g_value_get_pointer (value);
if (path_w == NULL)
break;
+ /* Construct only */
+ g_assert (priv->absolute_path_w == NULL);
priv->absolute_path_w = g_wcsdup (path_w, -1);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]