@@ -167,9 +167,23 @@ int bus_test_polkit(
167167
168168#if ENABLE_POLKIT
169169
170- typedef struct AsyncPolkitQuery {
170+ typedef struct AsyncPolkitQueryAction {
171171 char * action ;
172172 char * * details ;
173+ } AsyncPolkitQueryAction ;
174+
175+ static AsyncPolkitQueryAction * async_polkit_query_action_free (AsyncPolkitQueryAction * a ) {
176+ if (!a )
177+ return NULL ;
178+
179+ free (a -> action );
180+ strv_free (a -> details );
181+
182+ return mfree (a );
183+ }
184+
185+ typedef struct AsyncPolkitQuery {
186+ AsyncPolkitQueryAction * action ;
173187
174188 sd_bus_message * request , * reply ;
175189 sd_bus_slot * slot ;
@@ -190,8 +204,7 @@ static AsyncPolkitQuery *async_polkit_query_free(AsyncPolkitQuery *q) {
190204 sd_bus_message_unref (q -> request );
191205 sd_bus_message_unref (q -> reply );
192206
193- free (q -> action );
194- strv_free (q -> details );
207+ async_polkit_query_action_free (q -> action );
195208
196209 sd_event_source_disable_unref (q -> defer_event_source );
197210
@@ -285,12 +298,13 @@ static int process_polkit_response(
285298 assert (ret_error );
286299
287300 assert (q -> action );
301+ assert (q -> action -> action );
288302 assert (q -> reply );
289303
290304 /* If the operation we want to authenticate changed between the first and the second time,
291305 * let's not use this authentication, it might be out of date as the object and context we
292306 * operate on might have changed. */
293- if (!streq (q -> action , action ) || !strv_equal (q -> details , (char * * ) details ))
307+ if (!streq (q -> action -> action , action ) || !strv_equal (q -> action -> details , (char * * ) details ))
294308 return - ESTALE ;
295309
296310 if (sd_bus_message_is_method_error (q -> reply , NULL )) {
@@ -458,12 +472,15 @@ int bus_verify_polkit_async(
458472 .request = sd_bus_message_ref (call ),
459473 };
460474
461- q -> action = strdup ( action );
475+ q -> action = new ( AsyncPolkitQueryAction , 1 );
462476 if (!q -> action )
463477 return - ENOMEM ;
464478
465- q -> details = strv_copy ((char * * ) details );
466- if (!q -> details )
479+ * q -> action = (AsyncPolkitQueryAction ) {
480+ .action = strdup (action ),
481+ .details = strv_copy ((char * * ) details ),
482+ };
483+ if (!q -> action -> action || !q -> action -> details )
467484 return - ENOMEM ;
468485
469486 r = hashmap_put (* registry , call , q );
0 commit comments