]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_logprint: fix leak in error path of xlog_print_record()
authorEric Sandeen <sandeen@redhat.com>
Mon, 14 Apr 2014 06:12:43 +0000 (16:12 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 14 Apr 2014 06:12:43 +0000 (16:12 +1000)
In 2 error paths we returned without freeing the allocated buf.
Collapse them into a compound test & free buf on the way out.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
logprint/log_misc.c

index 52f1e85c30c52cb3947d8c30768d152c6818aa01..a022df42f78d178a1dfcfa1430ac1ed835c4087d 100644 (file)
@@ -942,11 +942,12 @@ xlog_print_record(
             */
            if (be32_to_cpu(rhead->h_cycle) !=
                        be32_to_cpu(*(__be32 *)ptr)) {
-               if (*read_type == FULL_READ)
-                   return -1;
-               else if (be32_to_cpu(rhead->h_cycle) + 1 !=
-                       be32_to_cpu(*(__be32 *)ptr))
-                   return -1;
+               if ((*read_type == FULL_READ) ||
+                   (be32_to_cpu(rhead->h_cycle) + 1 !=
+                               be32_to_cpu(*(__be32 *)ptr))) {
+                       free(buf);
+                       return -1;
+               }
            }
        }