]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
wimlib_mount_image(): Correctly return NOMEM in one case
[wimlib] / src / mount_image.c
index 7b3a91470d7c7c5c6b57df3412a4f49bf6dd9b52..41478d92a43dd8566c83c53a3f15bc35ff48c01a 100644 (file)
@@ -164,7 +164,8 @@ get_lookup_flags(const struct wimfs_context *ctx)
 static inline int
 flags_writable(int open_flags)
 {
-       return open_flags & (O_RDWR | O_WRONLY);
+       int accmode = (open_flags & O_ACCMODE);
+       return (accmode == O_RDWR || accmode == O_WRONLY);
 }
 
 /*
@@ -667,6 +668,7 @@ extract_resource_to_staging_dir(struct wim_inode *inode,
                }
        }
 
+       lte_put_resource(new_lte);
        new_lte->refcnt              = inode->i_nlink;
        new_lte->resource_location   = RESOURCE_IN_STAGING_FILE;
        new_lte->staging_file_name   = staging_file_name;
@@ -2474,8 +2476,10 @@ wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
        DEBUG("Preparing arguments to fuse_main()");
 
        dir_copy = STRDUP(dir);
-       if (!dir_copy)
+       if (!dir_copy) {
+               ret = WIMLIB_ERR_NOMEM;
                goto out_free_message_queue_names;
+       }
 
        argc = 0;
        argv[argc++] = "wimlib";