]> wimlib.net Git - wimlib/blobdiff - src/wim.c
begin_read(): Try fopen() before realpath()
[wimlib] / src / wim.c
index 92b59f02335cddb071a5e404e27f7cac1726c5c3..2278f2ebd051a1ff1d9a6df9e644c5262b3fcd89 100644 (file)
--- a/src/wim.c
+++ b/src/wim.c
@@ -418,12 +418,6 @@ static int begin_read(WIMStruct *w, const char *in_wim_path, int open_flags)
 
        DEBUG("Reading the WIM file `%s'", in_wim_path);
 
-       w->filename = realpath(in_wim_path, NULL);
-       if (!w->filename) {
-               ERROR("Failed to allocate memory for WIM filename");
-               return WIMLIB_ERR_NOMEM;
-       }
-
        w->fp = fopen(in_wim_path, "rb");
 
        if (!w->fp) {
@@ -432,6 +426,12 @@ static int begin_read(WIMStruct *w, const char *in_wim_path, int open_flags)
                return WIMLIB_ERR_OPEN;
        }
 
+       w->filename = realpath(in_wim_path, NULL);
+       if (!w->filename) {
+               ERROR("Failed to allocate memory for WIM filename");
+               return WIMLIB_ERR_NOMEM;
+       }
+
        ret = read_header(w->fp, &w->hdr, open_flags);
        if (ret != 0)
                return ret;