Browse code

Adds fix to EGG parser to free egg handle correctly, fixing minor memory leak.

Micah Snyder authored on 2019/08/15 02:07:21
Showing 1 changed files
... ...
@@ -1736,6 +1736,10 @@ static void egg_free_egg_handle(egg_handle* handle)
1736 1736
 {
1737 1737
     uint32_t i = 0;
1738 1738
 
1739
+    if (NULL == handle) {
1740
+        return;
1741
+    }
1742
+
1739 1743
     if (NULL != handle->encrypt) {
1740 1744
         egg_free_encrypt(handle->encrypt);
1741 1745
         handle->encrypt = NULL;
... ...
@@ -1764,6 +1768,7 @@ static void egg_free_egg_handle(egg_handle* handle)
1764 1764
         free(handle->comments);
1765 1765
         handle->comments = NULL;
1766 1766
     }
1767
+    free(handle);
1767 1768
 }
1768 1769
 
1769 1770
 static cl_error_t egg_parse_archive_headers(egg_handle* handle)
... ...
@@ -2105,8 +2110,9 @@ cl_error_t cli_egg_open(fmap_t* map, size_t sfx_offset, void** hArchive, char***
2105 2105
 
2106 2106
 done:
2107 2107
     if (CL_SUCCESS != status) {
2108
-        if (handle)
2108
+        if (handle) {
2109 2109
             egg_free_egg_handle(handle);
2110
+        }
2110 2111
         *hArchive = NULL;
2111 2112
     }
2112 2113
     return status;