Fix allocation size mismatch 33/199533/4
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Tue, 12 Feb 2019 13:48:10 +0000 (14:48 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 14 Feb 2019 14:40:28 +0000 (15:40 +0100)
Change-Id: Iee761aafd7f7cb63d12acc48345519faba821536

src/crash-manager/so-info.c

index 554edc4..cab1398 100644 (file)
@@ -313,12 +313,6 @@ GSList* create_tpk_list(rpmts ts)
                            strcmp(&file_name[file_name_len-4], ".tpk") != 0)
                                continue;
 
-                       struct rpm_file *rpm = (struct rpm_file*)malloc(sizeof(rpm));
-                       if (rpm == NULL) {
-                               _E("malloc() error (%m). Report (*.so_info) may be incomplete.");
-                               continue;
-                       }
-
                        const char *version = headerGetString(h, RPMTAG_VERSION);
                        const char *release = headerGetString(h, RPMTAG_RELEASE);
                        const char *arch = headerGetString(h, RPMTAG_ARCH);
@@ -326,6 +320,12 @@ GSList* create_tpk_list(rpmts ts)
                        if (version == NULL || release == NULL || arch == NULL)
                                continue;
 
+                       struct rpm_file *rpm = (struct rpm_file*)malloc(sizeof(*rpm));
+                       if (rpm == NULL) {
+                               _E("malloc() error (%m). Report (*.so_info) may be incomplete.");
+                               continue;
+                       }
+
                        if (asprintf(&rpm->pkg_name, "%s;%s;%s;%s",
                                        pkg_name, version, release, arch) == -1) {
                                _E("asprintf() error: %m");