Mailing List Archive

r3841 - in trunk/perl: t xs/KinoSearch/Index
Author: creamyg
Date: 2008-09-07 13:58:42 -0700 (Sun, 07 Sep 2008)
New Revision: 3841

Modified:
trunk/perl/t/204-doc_reader.t
trunk/perl/xs/KinoSearch/Index/DocReader.c
Log:
Fix segfaulting by DocReader_Fetch_Doc when presented with a zero-length field
value.


Modified: trunk/perl/t/204-doc_reader.t
===================================================================
--- trunk/perl/t/204-doc_reader.t 2008-09-07 20:56:43 UTC (rev 3840)
+++ trunk/perl/t/204-doc_reader.t 2008-09-07 20:58:42 UTC (rev 3841)
@@ -1,7 +1,7 @@
use strict;
use warnings;

-use Test::More tests => 5;
+use Test::More tests => 6;

package TestAnalyzer;
use base qw( KinoSearch::Analysis::Analyzer );
@@ -37,6 +37,7 @@
bin => 'MySchema::bin',
bincomp => 'MySchema::bincomp',
unstored => 'MySchema::unstored',
+ empty => 'text',
);

sub analyzer { TestAnalyzer->new }
@@ -69,6 +70,7 @@
bin => $bin_val,
bincomp => $bin_val,
unstored => $val,
+ empty => '',
}
);
$invindexer->finish;
@@ -89,3 +91,4 @@
is( $doc->{bin}, $bin_val, "bin" );
is( $doc->{bincomp}, $bin_val, "bincomp" );
is( $doc->{unstored}, undef, "unstored" );
+is( $doc->{empty}, '', "empty" );

Modified: trunk/perl/xs/KinoSearch/Index/DocReader.c
===================================================================
--- trunk/perl/xs/KinoSearch/Index/DocReader.c 2008-09-07 20:56:43 UTC (rev 3840)
+++ trunk/perl/xs/KinoSearch/Index/DocReader.c 2008-09-07 20:58:42 UTC (rev 3841)
@@ -50,7 +50,7 @@

/* Read the field value. */
value_len = Kino_InStream_Read_C32(ds_in);
- value_sv = newSV(value_len);
+ value_sv = newSV((value_len ? value_len : 1));
Kino_InStream_Read_Bytes(ds_in, SvPVX(value_sv), value_len);
SvCUR_set(value_sv, value_len);
*SvEND(value_sv) = '\0';


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits