summaryrefslogtreecommitdiffstats
path: root/src/mkid.c
diff options
context:
space:
mode:
authorClaudio Fontana <sick_soul@users.sourceforge.net>2005-12-15 14:27:19 +0000
committerClaudio Fontana <sick_soul@users.sourceforge.net>2005-12-15 14:27:19 +0000
commit30f93537e2f8579ff0c86b499bfc25d05f4eb079 (patch)
tree893461df05e62b86aa86bbb99bd122fd9d4c433f /src/mkid.c
parent484b6bb42940ec990c7a9a9679287955bae3dda8 (diff)
downloadidutils-30f93537e2f8579ff0c86b499bfc25d05f4eb079.tar.gz
idutils-30f93537e2f8579ff0c86b499bfc25d05f4eb079.tar.bz2
idutils-30f93537e2f8579ff0c86b499bfc25d05f4eb079.zip
* implemented fix for savannah support request sr #104712 and
added test case
Diffstat (limited to 'src/mkid.c')
-rw-r--r--src/mkid.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mkid.c b/src/mkid.c
index 147211f..2261111 100644
--- a/src/mkid.c
+++ b/src/mkid.c
@@ -289,6 +289,21 @@ main (int argc, char **argv)
mark_member_file_links (&idh);
log_8_member_files = ceil_log_8 (idh.idh_member_file_table.ht_fill);
+
+ /* hack start: when scanning a single file, log_8_member_files results 0.
+ Adjust to 1 in this case, or xmalloc will be called for 0 bytes,
+ and later the struct token will have no 'hits' field.
+ This would cause a crash
+ (see testsuite/consistency, testsuite/single_file_token_bug.c)
+
+ <claudio@gnu.org 2005>
+ */
+
+ if (log_8_member_files == 0)
+ log_8_member_files = 1;
+
+ /* hack end */
+
current_hits_signature = xmalloc (log_8_member_files);
/* If scannable files were given, then scan them. */
@@ -327,7 +342,7 @@ ceil_log_8 (unsigned long n)
return log_8;
}
-/* Return the integer ceiling of the base-8 logarithm of N. */
+/* Return the integer ceiling of the base-2 logarithm of N. */
int
ceil_log_2 (unsigned long n)