[crush-tools] r538 committed - hashjoin: bug fix - when input has only a header line, xmalloc recieve...

4 views
Skip to first unread message

crush...@googlecode.com

unread,
Dec 5, 2014, 11:00:51 AM12/5/14
to crush...@googlegroups.com
Revision: 538
Author: jeremy...@gmail.com
Date: Fri Dec 5 15:59:56 2014 UTC
Log: hashjoin: bug fix - when input has only a header line, xmalloc
recieved uninitialized size argument.

https://code.google.com/p/crush-tools/source/detail?r=538

Added:
/trunk/src/hashjoin/test/test_08.expected
/trunk/src/hashjoin/test/test_08.sh
Modified:
/trunk/src/hashjoin/hashjoin.c

=======================================
--- /dev/null
+++ /trunk/src/hashjoin/test/test_08.expected Fri Dec 5 15:59:56 2014 UTC
@@ -0,0 +1,1 @@
+Field-0,Field-1,Something-Else,Field-2,Field-3
=======================================
--- /dev/null
+++ /trunk/src/hashjoin/test/test_08.sh Fri Dec 5 15:59:56 2014 UTC
@@ -0,0 +1,18 @@
+test_number=08
+description="join by index with header-only input"
+
+infile="$test_dir/input_header.log"
+dimfile="$test_dir/dimension_header.log"
+outfile="$test_dir/test_$test_number.actual"
+expected="$test_dir/test_$test_number.expected"
+
+head -1 $infile | $bin -k 1,2 -l 1,2 -j 3,4 -f $dimfile \
+ > "$outfile"
+
+if [ $? -ne 0 ] ||
+ [ "`diff -q $outfile $expected`" ]; then
+ test_status $test_number 1 "$description" FAIL
+else
+ test_status $test_number 1 "$description" PASS
+ rm "$outfile"
+fi
=======================================
--- /trunk/src/hashjoin/hashjoin.c Fri Apr 4 16:53:41 2014 UTC
+++ /trunk/src/hashjoin/hashjoin.c Fri Dec 5 15:59:56 2014 UTC
@@ -135,6 +135,12 @@
printf("%s%s%s\n", datareader->current_line,
args->delim, args->dimension_labels);
}
+
+ /* If the input has only a header row, quit now. */
+ if (datareader->next_line == NULL) {
+ infile = nextfile(argc, argv, &optind, "r");
+ continue;
+ }

if (! keybuffer) {
keybuffer = xmalloc(datareader->next_line_len);
Reply all
Reply to author
Forward
0 new messages