imv-os: Properly free strings for invalid input in pacman
authorTobias Brunner <tobias@strongswan.org>
Thu, 27 Aug 2015 12:41:13 +0000 (14:41 +0200)
committerTobias Brunner <tobias@strongswan.org>
Thu, 27 Aug 2015 12:42:05 +0000 (14:42 +0200)
src/libimcv/plugins/imv_os/pacman.c

index 019e2ad..088313c 100644 (file)
@@ -396,6 +396,17 @@ static void process_packages(char *filename, char *product, bool security)
                                pacman_state = PACMAN_STATE_BEGIN_PACKAGE;
                }
        }
+       switch (pacman_state)
+       {
+               case PACMAN_STATE_END_PACKAGE:
+                       free(version);
+                       /* fall-through */
+               case PACMAN_STATE_VERSION:
+                       free(package);
+                       break;
+               default:
+                       break;
+       }
        fclose(file);
        db->destroy(db);