]> wimlib.net Git - wimlib/blobdiff - src/lookup_table.c
extract_resource_to_staging_dir(): Fix memory leak
[wimlib] / src / lookup_table.c
index 4a3bc1e23b4f3f0f4173f9fa0a4ed28a0d3f2a02..098a8aaf194b2dce63a15b97b7127d48e6814c72 100644 (file)
@@ -190,41 +190,47 @@ out_free:
 }
 
 void
-free_lookup_table_entry(struct wim_lookup_table_entry *lte)
+lte_put_resource(struct wim_lookup_table_entry *lte)
 {
-       if (lte) {
-               switch (lte->resource_location) {
-               case RESOURCE_IN_WIM:
-                       list_del(&lte->rspec_node);
-                       if (list_empty(&lte->rspec->stream_list))
-                               FREE(lte->rspec);
-                       break;
-               case RESOURCE_IN_FILE_ON_DISK:
-       #ifdef __WIN32__
-               case RESOURCE_WIN32_ENCRYPTED:
-       #endif
-       #ifdef WITH_FUSE
-               case RESOURCE_IN_STAGING_FILE:
-                       BUILD_BUG_ON((void*)&lte->file_on_disk !=
-                                    (void*)&lte->staging_file_name);
-       #endif
-               case RESOURCE_IN_ATTACHED_BUFFER:
-                       BUILD_BUG_ON((void*)&lte->file_on_disk !=
-                                    (void*)&lte->attached_buffer);
-                       FREE(lte->file_on_disk);
-                       break;
-#ifdef WITH_NTFS_3G
-               case RESOURCE_IN_NTFS_VOLUME:
-                       if (lte->ntfs_loc) {
-                               FREE(lte->ntfs_loc->path);
-                               FREE(lte->ntfs_loc->stream_name);
-                               FREE(lte->ntfs_loc);
-                       }
-                       break;
+       switch (lte->resource_location) {
+       case RESOURCE_IN_WIM:
+               list_del(&lte->rspec_node);
+               if (list_empty(&lte->rspec->stream_list))
+                       FREE(lte->rspec);
+               break;
+       case RESOURCE_IN_FILE_ON_DISK:
+#ifdef __WIN32__
+       case RESOURCE_WIN32_ENCRYPTED:
 #endif
-               default:
-                       break;
+#ifdef WITH_FUSE
+       case RESOURCE_IN_STAGING_FILE:
+               BUILD_BUG_ON((void*)&lte->file_on_disk !=
+                            (void*)&lte->staging_file_name);
+#endif
+       case RESOURCE_IN_ATTACHED_BUFFER:
+               BUILD_BUG_ON((void*)&lte->file_on_disk !=
+                            (void*)&lte->attached_buffer);
+               FREE(lte->file_on_disk);
+               break;
+#ifdef WITH_NTFS_3G
+       case RESOURCE_IN_NTFS_VOLUME:
+               if (lte->ntfs_loc) {
+                       FREE(lte->ntfs_loc->path);
+                       FREE(lte->ntfs_loc->stream_name);
+                       FREE(lte->ntfs_loc);
                }
+               break;
+#endif
+       default:
+               break;
+       }
+}
+
+void
+free_lookup_table_entry(struct wim_lookup_table_entry *lte)
+{
+       if (lte) {
+               lte_put_resource(lte);
                FREE(lte);
        }
 }