btrfs-progs: fix regexec to only work if we actually have a regexec
authorJosef Bacik <josef@redhat.com>
Fri, 2 Dec 2011 17:52:15 +0000 (12:52 -0500)
committerDavid Sterba <dsterba@suse.cz>
Fri, 9 Aug 2013 12:32:30 +0000 (14:32 +0200)
We were unconditionally executing our regular expression, even though we may not
have one, so check to make sure mreg is not null before calling regexec.
Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
cmds-restore.c

index 1aae390..3be6e71 100644 (file)
@@ -649,7 +649,7 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key,
                /* full path from root of btrfs being restored */
                snprintf(fs_name, 4096, "%s/%s", dir, filename);
 
-               if (REG_NOMATCH == regexec(mreg, fs_name, 0, NULL, 0))
+               if (mreg && REG_NOMATCH == regexec(mreg, fs_name, 0, NULL, 0))
                        goto next;
 
                /* full path from system root */