Fix static analysis issue 31/213231/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 3 Sep 2019 06:03:07 +0000 (15:03 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Wed, 4 Sep 2019 04:24:46 +0000 (04:24 +0000)
Fix null pointer dereference.

Change-Id: I4088bc6a36e6f1cd936643f00ddb623af97c55dd
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/pkg_upgrade.c

index 1dcddcd..ff9bc05 100644 (file)
@@ -843,7 +843,16 @@ static int __find_matched_pkgid_from_list(const char *source_file,
                        continue;
 
                version = __getvalue(buf, TOKEN_VERSION_STR, 1);
+               if (version == NULL) {
+                       free(pkgid);
+                       continue;
+               }
                pkgtype = __getvalue(buf, TOKEN_TYPE_STR, 1);
+               if (pkgtype == NULL) {
+                       free(version);
+                       free(pkgid);
+                       continue;
+               }
 
                compare_result = __compare_pkgid((char *)target_file, pkgid,
                                                version, &db_update);