From 30f93537e2f8579ff0c86b499bfc25d05f4eb079 Mon Sep 17 00:00:00 2001 From: Claudio Fontana Date: Thu, 15 Dec 2005 14:27:19 +0000 Subject: * implemented fix for savannah support request sr #104712 and added test case --- src/mkid.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') 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) + + + */ + + 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) -- cgit v1.2.3