Bruno Wolff III 2517a9
diff --git a/squashfs-tools/unsquash-4.c b/squashfs-tools/unsquash-4.c
Bruno Wolff III e68da2
index ecdaac796f09..2c0cf63daf67 100644
Bruno Wolff III 2517a9
--- a/squashfs-tools/unsquash-4.c
Bruno Wolff III 2517a9
+++ b/squashfs-tools/unsquash-4.c
Bruno Wolff III e68da2
@@ -31,9 +31,9 @@ static unsigned int *id_table;
Bruno Wolff III e68da2
 int read_fragment_table_4(long long *directory_table_end)
Bruno Wolff III e68da2
 {
Bruno Wolff III e68da2
 	int res, i;
Bruno Wolff III e68da2
-	int bytes = SQUASHFS_FRAGMENT_BYTES(sBlk.s.fragments);
Bruno Wolff III e68da2
-	int  indexes = SQUASHFS_FRAGMENT_INDEXES(sBlk.s.fragments);
Bruno Wolff III e68da2
-	long long fragment_table_index[indexes];
Bruno Wolff III e68da2
+	size_t bytes = SQUASHFS_FRAGMENT_BYTES(sBlk.s.fragments);
Bruno Wolff III e68da2
+	size_t indexes = SQUASHFS_FRAGMENT_INDEXES(sBlk.s.fragments);
Bruno Wolff III e68da2
+	long long *fragment_table_index;
Bruno Wolff III e68da2
 
Bruno Wolff III e68da2
 	TRACE("read_fragment_table: %d fragments, reading %d fragment indexes "
Bruno Wolff III e68da2
 		"from 0x%llx\n", sBlk.s.fragments, indexes,
Bruno Wolff III e68da2
@@ -44,6 +44,11 @@ int read_fragment_table_4(long long *directory_table_end)
Bruno Wolff III e68da2
 		return TRUE;
Bruno Wolff III e68da2
 	}
Bruno Wolff III e68da2
 
Bruno Wolff III e68da2
+	fragment_table_index = malloc(indexes*sizeof(long long));
Bruno Wolff III e68da2
+	if(fragment_table_index == NULL)
Bruno Wolff III e68da2
+		EXIT_UNSQUASH("read_fragment_table: failed to allocate "
Bruno Wolff III e68da2
+			"fragment table index\n");
Bruno Wolff III e68da2
+
Bruno Wolff III e68da2
 	fragment_table = malloc(bytes);
Bruno Wolff III e68da2
 	if(fragment_table == NULL)
Bruno Wolff III e68da2
 		EXIT_UNSQUASH("read_fragment_table: failed to allocate "