write.c: Fix handling of NULL context in stream_filtered()
authorEric Biggers <ebiggers3@gmail.com>
Tue, 5 Aug 2014 01:46:24 +0000 (20:46 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 5 Aug 2014 01:52:24 +0000 (20:52 -0500)
A NULL filter_context is supposed to be valid and interpreted as "don't
filter anything".  This case can't be triggered by wimlib-imagex, but it
might be possible via custom library calls.

src/write.c

index 91954f9f023b66f6fd96f122bd117ab86e58e2f7..39e8bd0af5a8c75002cb47c17fbd524e0529e694 100644 (file)
@@ -102,12 +102,15 @@ static int
 stream_filtered(const struct wim_lookup_table_entry *lte,
                const struct filter_context *ctx)
 {
-       int write_flags = ctx->write_flags;
-       WIMStruct *wim = ctx->wim;
+       int write_flags;
+       WIMStruct *wim;
 
        if (ctx == NULL)
                return 0;
 
+       write_flags = ctx->write_flags;
+       wim = ctx->wim;
+
        if (write_flags & WIMLIB_WRITE_FLAG_OVERWRITE &&
            lte->resource_location == RESOURCE_IN_WIM &&
            lte->rspec->wim == wim)