Bug Summary

File:ctk/ctkcolorpickerportal.c
Warning:line 210, column 37
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ctkcolorpickerportal.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/ctk -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Ctk" -D G_LOG_USE_STRUCTURED=1 -D CTK_VERSION="3.25.5" -D CTK_BINARY_VERSION="3.0.0" -D CTK_COMPILATION -D CTK_PRINT_BACKEND_ENABLE_UNSUPPORTED -D CTK_LIBDIR="/usr/lib" -D CTK_LOCALEDIR="/usr/share/locale" -D CTK_DATADIR="/usr/share" -D CTK_DATA_PREFIX="/usr" -D CTK_SYSCONFDIR="/usr/etc" -D CTK_HOST="x86_64-pc-linux-gnu" -D CTK_PRINT_BACKENDS="file,cups" -D X11_DATA_PREFIX="/usr" -D ISO_CODES_PREFIX="" -I .. -I ../ctk -I .. -I ../cdk -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -D G_ENABLE_DEBUG -D G_ENABLE_CONSISTENCY_CHECKS -D GLIB_MIN_REQUIRED_VERSION=GLIB_VERSION_2_66 -D GLIB_MAX_ALLOWED_VERSION=GLIB_VERSION_2_66 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/atk-1.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gio-unix-2.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -D PIC -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/ctk -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-19-172241-43638-1 -x c ctkcolorpickerportal.c
1/* CTK - The GIMP Toolkit
2 * Copyright (C) 2018, Red Hat, Inc
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "config.h"
19
20#include "ctkcolorpickerportalprivate.h"
21#include "ctkprivate.h"
22#include <gio/gio.h>
23
24struct _CtkColorPickerPortal
25{
26 GObject parent_instance;
27
28 GDBusProxy *portal_proxy;
29 guint portal_signal_id;
30 GTask *task;
31};
32
33struct _CtkColorPickerPortalClass
34{
35 GObjectClass parent_class;
36};
37
38static GInitableIface *initable_parent_iface;
39static void ctk_color_picker_portal_initable_iface_init (GInitableIface *iface);
40static void ctk_color_picker_portal_iface_init (CtkColorPickerInterface *iface);
41
42G_DEFINE_TYPE_WITH_CODE (CtkColorPickerPortal, ctk_color_picker_portal, G_TYPE_OBJECT,static void ctk_color_picker_portal_init (CtkColorPickerPortal
*self); static void ctk_color_picker_portal_class_init (CtkColorPickerPortalClass
*klass); static GType ctk_color_picker_portal_get_type_once (
void); static gpointer ctk_color_picker_portal_parent_class =
((void*)0); static gint CtkColorPickerPortal_private_offset;
static void ctk_color_picker_portal_class_intern_init (gpointer
klass) { ctk_color_picker_portal_parent_class = g_type_class_peek_parent
(klass); if (CtkColorPickerPortal_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkColorPickerPortal_private_offset); ctk_color_picker_portal_class_init
((CtkColorPickerPortalClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer ctk_color_picker_portal_get_instance_private
(CtkColorPickerPortal *self) { return (((gpointer) ((guint8*
) (self) + (glong) (CtkColorPickerPortal_private_offset)))); }
GType ctk_color_picker_portal_get_type (void) { static GType
static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); (void) (0 ? (gpointer) * (
&static_g_define_type_id) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= ctk_color_picker_portal_get_type_once (); (__extension__ (
{ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof
(gpointer), "Expression evaluates to false"); 0 ? (void) (*(
&static_g_define_type_id) = (g_define_type_id)) : (void) 0
; g_once_init_leave_pointer ((&static_g_define_type_id), (
gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ctk_color_picker_portal_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("CtkColorPickerPortal"
), sizeof (CtkColorPickerPortalClass), (GClassInitFunc)(void (
*)(void)) ctk_color_picker_portal_class_intern_init, sizeof (
CtkColorPickerPortal), (GInstanceInitFunc)(void (*)(void)) ctk_color_picker_portal_init
, (GTypeFlags) 0); { {{ const GInterfaceInfo g_implement_interface_info
= { (GInterfaceInitFunc)(void (*)(void)) ctk_color_picker_portal_initable_iface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (g_initable_get_type ()), &g_implement_interface_info);
} { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) ctk_color_picker_portal_iface_init, ((void*
)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (ctk_color_picker_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
43 G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, ctk_color_picker_portal_initable_iface_init)static void ctk_color_picker_portal_init (CtkColorPickerPortal
*self); static void ctk_color_picker_portal_class_init (CtkColorPickerPortalClass
*klass); static GType ctk_color_picker_portal_get_type_once (
void); static gpointer ctk_color_picker_portal_parent_class =
((void*)0); static gint CtkColorPickerPortal_private_offset;
static void ctk_color_picker_portal_class_intern_init (gpointer
klass) { ctk_color_picker_portal_parent_class = g_type_class_peek_parent
(klass); if (CtkColorPickerPortal_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkColorPickerPortal_private_offset); ctk_color_picker_portal_class_init
((CtkColorPickerPortalClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer ctk_color_picker_portal_get_instance_private
(CtkColorPickerPortal *self) { return (((gpointer) ((guint8*
) (self) + (glong) (CtkColorPickerPortal_private_offset)))); }
GType ctk_color_picker_portal_get_type (void) { static GType
static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); (void) (0 ? (gpointer) * (
&static_g_define_type_id) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= ctk_color_picker_portal_get_type_once (); (__extension__ (
{ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof
(gpointer), "Expression evaluates to false"); 0 ? (void) (*(
&static_g_define_type_id) = (g_define_type_id)) : (void) 0
; g_once_init_leave_pointer ((&static_g_define_type_id), (
gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ctk_color_picker_portal_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("CtkColorPickerPortal"
), sizeof (CtkColorPickerPortalClass), (GClassInitFunc)(void (
*)(void)) ctk_color_picker_portal_class_intern_init, sizeof (
CtkColorPickerPortal), (GInstanceInitFunc)(void (*)(void)) ctk_color_picker_portal_init
, (GTypeFlags) 0); { {{ const GInterfaceInfo g_implement_interface_info
= { (GInterfaceInitFunc)(void (*)(void)) ctk_color_picker_portal_initable_iface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (g_initable_get_type ()), &g_implement_interface_info);
} { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) ctk_color_picker_portal_iface_init, ((void*
)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (ctk_color_picker_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
44 G_IMPLEMENT_INTERFACE (CTK_TYPE_COLOR_PICKER, ctk_color_picker_portal_iface_init))static void ctk_color_picker_portal_init (CtkColorPickerPortal
*self); static void ctk_color_picker_portal_class_init (CtkColorPickerPortalClass
*klass); static GType ctk_color_picker_portal_get_type_once (
void); static gpointer ctk_color_picker_portal_parent_class =
((void*)0); static gint CtkColorPickerPortal_private_offset;
static void ctk_color_picker_portal_class_intern_init (gpointer
klass) { ctk_color_picker_portal_parent_class = g_type_class_peek_parent
(klass); if (CtkColorPickerPortal_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CtkColorPickerPortal_private_offset); ctk_color_picker_portal_class_init
((CtkColorPickerPortalClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer ctk_color_picker_portal_get_instance_private
(CtkColorPickerPortal *self) { return (((gpointer) ((guint8*
) (self) + (glong) (CtkColorPickerPortal_private_offset)))); }
GType ctk_color_picker_portal_get_type (void) { static GType
static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); (void) (0 ? (gpointer) * (
&static_g_define_type_id) : ((void*)0)); (!(__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= ctk_color_picker_portal_get_type_once (); (__extension__ (
{ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof
(gpointer), "Expression evaluates to false"); 0 ? (void) (*(
&static_g_define_type_id) = (g_define_type_id)) : (void) 0
; g_once_init_leave_pointer ((&static_g_define_type_id), (
gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType ctk_color_picker_portal_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("CtkColorPickerPortal"
), sizeof (CtkColorPickerPortalClass), (GClassInitFunc)(void (
*)(void)) ctk_color_picker_portal_class_intern_init, sizeof (
CtkColorPickerPortal), (GInstanceInitFunc)(void (*)(void)) ctk_color_picker_portal_init
, (GTypeFlags) 0); { {{ const GInterfaceInfo g_implement_interface_info
= { (GInterfaceInitFunc)(void (*)(void)) ctk_color_picker_portal_initable_iface_init
, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (g_initable_get_type ()), &g_implement_interface_info);
} { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc
)(void (*)(void)) ctk_color_picker_portal_iface_init, ((void*
)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id
, (ctk_color_picker_get_type ()), &g_implement_interface_info
); };} } return g_define_type_id; }
45
46static gboolean
47ctk_color_picker_portal_initable_init (GInitable *initable,
48 GCancellable *cancellable G_GNUC_UNUSED__attribute__ ((__unused__)),
49 GError **error)
50{
51 CtkColorPickerPortal *picker = CTK_COLOR_PICKER_PORTAL (initable);
52 char *owner;
53 GVariant *ret;
54 guint version = 0;
55
56 if (!ctk_should_use_portal ())
57 return FALSE(0);
58
59 picker->portal_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
60 G_DBUS_PROXY_FLAGS_NONE,
61 NULL((void*)0),
62 "org.freedesktop.portal.Desktop",
63 "/org/freedesktop/portal/desktop",
64 "org.freedesktop.portal.Screenshot",
65 NULL((void*)0),
66 error);
67
68 if (picker->portal_proxy == NULL((void*)0))
69 {
70 g_debug ("Failed to create screenshot portal proxy");
71 return FALSE(0);
72 }
73
74 owner = g_dbus_proxy_get_name_owner (picker->portal_proxy);
75 if (owner == NULL((void*)0))
76 {
77 g_debug ("org.freedesktop.portal.Screenshot not provided");
78 g_clear_object (&picker->portal_proxy)do { _Static_assert (sizeof *((&picker->portal_proxy))
== sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&picker->portal_proxy))) _pp = ((&picker->portal_proxy
)); __typeof__ (*((&picker->portal_proxy))) _ptr = *_pp
; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
79 return FALSE(0);
80 }
81 g_free (owner);
82
83 ret = g_dbus_proxy_get_cached_property (picker->portal_proxy, "version");
84 if (ret)
85 {
86 version = g_variant_get_uint32 (ret);
87 g_variant_unref (ret);
88 }
89
90 if (version != 2)
91 {
92 g_debug ("Screenshot portal version: %u", version);
93 g_clear_object (&picker->portal_proxy)do { _Static_assert (sizeof *((&picker->portal_proxy))
== sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&picker->portal_proxy))) _pp = ((&picker->portal_proxy
)); __typeof__ (*((&picker->portal_proxy))) _ptr = *_pp
; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
94 return FALSE(0);
95 }
96
97 return TRUE(!(0));
98}
99
100static void
101ctk_color_picker_portal_initable_iface_init (GInitableIface *iface)
102{
103 initable_parent_iface = g_type_interface_peek_parent (iface);
104 iface->init = ctk_color_picker_portal_initable_init;
105}
106
107static void
108ctk_color_picker_portal_init (CtkColorPickerPortal *picker G_GNUC_UNUSED__attribute__ ((__unused__)))
109{
110}
111
112static void
113ctk_color_picker_portal_finalize (GObject *object)
114{
115 CtkColorPickerPortal *picker = CTK_COLOR_PICKER_PORTAL (object);
116
117 g_clear_object (&picker->portal_proxy)do { _Static_assert (sizeof *((&picker->portal_proxy))
== sizeof (gpointer), "Expression evaluates to false"); __typeof__
(((&picker->portal_proxy))) _pp = ((&picker->portal_proxy
)); __typeof__ (*((&picker->portal_proxy))) _ptr = *_pp
; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while
(0)
;
118
119 G_OBJECT_CLASS (ctk_color_picker_portal_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((ctk_color_picker_portal_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
120}
121
122static void
123ctk_color_picker_portal_class_init (CtkColorPickerPortalClass *class)
124{
125 GObjectClass *object_class = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((class)), (((GType) ((20) << (2))))))))
;
126
127 object_class->finalize = ctk_color_picker_portal_finalize;
128}
129
130CtkColorPicker *
131ctk_color_picker_portal_new (void)
132{
133 return CTK_COLOR_PICKER (g_initable_new (CTK_TYPE_COLOR_PICKER_PORTAL, NULL, NULL, NULL))((((CtkColorPicker*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_initable_new (ctk_color_picker_portal_get_type (), ((void
*)0), ((void*)0), ((void*)0)))), ((ctk_color_picker_get_type (
)))))))
;
134}
135
136static void
137portal_response_received (GDBusConnection *connection,
138 const char *sender_name G_GNUC_UNUSED__attribute__ ((__unused__)),
139 const char *object_path G_GNUC_UNUSED__attribute__ ((__unused__)),
140 const char *interface_name G_GNUC_UNUSED__attribute__ ((__unused__)),
141 const char *signal_name G_GNUC_UNUSED__attribute__ ((__unused__)),
142 GVariant *parameters,
143 gpointer user_data)
144{
145 CtkColorPickerPortal *picker = user_data;
146 guint32 response;
147 GVariant *ret;
148
149 g_dbus_connection_signal_unsubscribe (connection, picker->portal_signal_id);
150 picker->portal_signal_id = 0;
151
152 g_variant_get (parameters, "(u@a{sv})", &response, &ret);
153
154 if (response == 0)
155 {
156 CdkRGBA c;
157
158 c.alpha = 1.0;
159 if (g_variant_lookup (ret, "color", "(ddd)", &c.red, &c.green, &c.blue))
160 g_task_return_pointer (picker->task, cdk_rgba_copy (&c), (GDestroyNotify)cdk_rgba_free);
161 else
162 g_task_return_new_error (picker->task,
163 G_IO_ERRORg_io_error_quark(),
164 G_IO_ERROR_FAILED,
165 "No color received");
166 }
167 else
168 g_task_return_new_error (picker->task,
169 G_IO_ERRORg_io_error_quark(),
170 G_IO_ERROR_FAILED,
171 "PickColor error");
172
173 g_variant_unref (ret);
174
175 g_clear_object (&picker->task)do { _Static_assert (sizeof *((&picker->task)) == sizeof
(gpointer), "Expression evaluates to false"); __typeof__ (((
&picker->task))) _pp = ((&picker->task)); __typeof__
(*((&picker->task))) _ptr = *_pp; *_pp = ((void*)0); if
(_ptr) (g_object_unref) (_ptr); } while (0)
;
176}
177
178static void
179ctk_color_picker_portal_pick (CtkColorPicker *cp,
180 GAsyncReadyCallback callback,
181 gpointer user_data)
182{
183 CtkColorPickerPortal *picker = CTK_COLOR_PICKER_PORTAL (cp);
184 GVariantBuilder options;
185 GDBusConnection *connection;
186 char *token;
187 char *handle;
188
189 if (picker->task)
190 return;
191
192 picker->task = g_task_new (picker, NULL((void*)0), callback, user_data);
193
194 connection = g_dbus_proxy_get_connection (picker->portal_proxy);
195
196 handle = ctk_get_portal_request_path (connection, &token);
197 picker->portal_signal_id = g_dbus_connection_signal_subscribe (connection,
198 "org.freedesktop.portal.Desktop",
199 "org.freedesktop.portal.Request",
200 "Response",
201 handle,
202 NULL((void*)0),
203 G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE,
204 portal_response_received,
205 picker,
206 NULL((void*)0));
207
208 g_free (handle);
209
210 g_variant_builder_init (&options, G_VARIANT_TYPE_VARDICT((const GVariantType *) "a{sv}"));
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption
211 g_variant_builder_add (&options, "{sv}", "handle_token", g_variant_new_string (token));
212 g_free (token);
213
214 g_dbus_proxy_call (picker->portal_proxy,
215 "PickColor",
216 g_variant_new ("(sa{sv})", "", &options),
217 0,
218 -1,
219 NULL((void*)0),
220 NULL((void*)0),
221 NULL((void*)0));
222}
223
224static CdkRGBA *
225ctk_color_picker_portal_pick_finish (CtkColorPicker *cp,
226 GAsyncResult *res,
227 GError **error)
228{
229 g_return_val_if_fail (g_task_is_valid (res, cp), NULL)do { if ((g_task_is_valid (res, cp))) { } else { g_return_if_fail_warning
("Ctk", ((const char*) (__func__)), "g_task_is_valid (res, cp)"
); return (((void*)0)); } } while (0)
;
230
231 return g_task_propagate_pointer (G_TASK (res)((((GTask*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((res)), ((g_task_get_type ()))))))
, error);
232}
233
234static void
235ctk_color_picker_portal_iface_init (CtkColorPickerInterface *iface)
236{
237 iface->pick = ctk_color_picker_portal_pick;
238 iface->pick_finish = ctk_color_picker_portal_pick_finish;
239}