simplify string duplication 38/202538/2
authorAdrian Szyndela <adrian.s@samsung.com>
Wed, 20 Mar 2019 13:43:26 +0000 (14:43 +0100)
committerAdrian Szyndela <adrian.s@samsung.com>
Mon, 1 Apr 2019 09:42:15 +0000 (11:42 +0200)
Change-Id: Ie228964fcabf0f3fea8225e80ed2cdf82d12119d

src/libdbuspolicy1.c

index c3f9fa7..9e2e609 100644 (file)
@@ -508,10 +508,9 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration,
                dest_uid_n = info.uid_n;
                dest_gid_n = info.gid_n;
 
-               if (info.label) {
-                       dest_label = (char*)malloc(sizeof(char) * strlen(info.label) + 1);
-                       strncpy(dest_label, info.label, strlen(info.label) + 1);
-               }
+               if (info.label)
+                       dest_label = strdup(info.label);
+
                if (free_conn_info) {
                        kdbus_free_by_offset(kconn->fd, info.free_offset);
                        free_conn_info = false;