]> wimlib.net Git - wimlib/blobdiff - src/export_image.c
Don't immediately discard streams with 0 references
[wimlib] / src / export_image.c
index 56725e668bb77b113a4bf67fdd6b3c49476e051a..8d449ea93439d634b002aacea0287c1f66c3a88b 100644 (file)
@@ -87,10 +87,12 @@ lte_unexport(struct wim_lookup_table_entry *lte, void *_lookup_table)
 {
        struct wim_lookup_table *lookup_table = _lookup_table;
 
 {
        struct wim_lookup_table *lookup_table = _lookup_table;
 
-       lte->refcnt -= lte->out_refcnt;
-       if (lte->refcnt == 0) {
-               lookup_table_unlink(lookup_table, lte);
-               free_lookup_table_entry(lte);
+       if (lte->out_refcnt) {
+               lte->refcnt -= lte->out_refcnt;
+               if (lte->refcnt == 0) {
+                       lookup_table_unlink(lookup_table, lte);
+                       free_lookup_table_entry(lte);
+               }
        }
        return 0;
 }
        }
        return 0;
 }
@@ -113,6 +115,11 @@ wimlib_export_image(WIMStruct *src_wim,
        u32 orig_dest_image_count;
 
        /* Check for sane parameters.  */
        u32 orig_dest_image_count;
 
        /* Check for sane parameters.  */
+       if (export_flags & ~(WIMLIB_EXPORT_FLAG_BOOT |
+                            WIMLIB_EXPORT_FLAG_NO_NAMES |
+                            WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS))
+               return WIMLIB_ERR_INVALID_PARAM;
+
        if (src_wim == NULL || dest_wim == NULL)
                return WIMLIB_ERR_INVALID_PARAM;
 
        if (src_wim == NULL || dest_wim == NULL)
                return WIMLIB_ERR_INVALID_PARAM;
 
@@ -174,7 +181,7 @@ wimlib_export_image(WIMStruct *src_wim,
                /* Determine destination image name and description.  */
 
                if (export_flags & WIMLIB_EXPORT_FLAG_NO_NAMES) {
                /* Determine destination image name and description.  */
 
                if (export_flags & WIMLIB_EXPORT_FLAG_NO_NAMES) {
-                       next_dest_name = NULL;
+                       next_dest_name = T("");
                } else if (dest_name) {
                        next_dest_name = dest_name;
                } else {
                } else if (dest_name) {
                        next_dest_name = dest_name;
                } else {
@@ -185,8 +192,8 @@ wimlib_export_image(WIMStruct *src_wim,
                DEBUG("Using name \"%"TS"\"", next_dest_name);
 
                if (export_flags & WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS) {
                DEBUG("Using name \"%"TS"\"", next_dest_name);
 
                if (export_flags & WIMLIB_EXPORT_FLAG_NO_DESCRIPTIONS) {
-                       next_dest_description = NULL;
-               } if (dest_description) {
+                       next_dest_description = T("");
+               } else if (dest_description) {
                        next_dest_description = dest_description;
                } else {
                        next_dest_description = wimlib_get_image_description(
                        next_dest_description = dest_description;
                } else {
                        next_dest_description = wimlib_get_image_description(