e4defrag: Fix a core dump when trying to defrag a file with no blocks

Signed-off-by Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index 05d6893..1c7c012 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -1303,6 +1303,15 @@
 		return 0;
 	}
 
+	/* Has no blocks */
+	if (buf->st_blocks == 0) {
+		if (mode_flag & DETAIL) {
+			PRINT_FILE_NAME(file);
+			STATISTIC_ERR_MSG("File has no blocks");
+		}
+		return 0;
+	}
+
 	fd = open64(file, O_RDONLY);
 	if (fd < 0) {
 		if (mode_flag & DETAIL) {
@@ -1624,6 +1633,15 @@
 		return 0;
 	}
 
+	/* Has no blocks */
+	if (buf->st_blocks == 0) {
+		if (mode_flag & DETAIL) {
+			PRINT_FILE_NAME(file);
+			STATISTIC_ERR_MSG("File has no blocks");
+		}
+		return 0;
+	}
+
 	fd = open64(file, O_RDONLY);
 	if (fd < 0) {
 		if (mode_flag & DETAIL) {