[Namazu-cvs 856] r268 - Search-Namazu/branches/0.96/Search-Namazu

cvsd @ vaj.namazu.org cvsd @ vaj.namazu.org
2006年 6月 9日 (金) 14:48:58 JST


Author: knok
Date: 2006-06-09 14:48:57 +0900 (Fri, 09 Jun 2006)
New Revision: 268

Modified:
   Search-Namazu/branches/0.96/Search-Namazu/ChangeLog
   Search-Namazu/branches/0.96/Search-Namazu/Namazu.xs
Log:
Fixed segfault bug.


Modified: Search-Namazu/branches/0.96/Search-Namazu/ChangeLog
===================================================================
--- Search-Namazu/branches/0.96/Search-Namazu/ChangeLog	2006-06-09 05:43:51 UTC (rev 267)
+++ Search-Namazu/branches/0.96/Search-Namazu/ChangeLog	2006-06-09 05:48:57 UTC (rev 268)
@@ -1,3 +1,8 @@
+2006-06-09  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
+
+	* Namazu.xs: Fixed segfault bug on perl 5.005_03.
+	  (Patched by Tadamasa Teranishi, thank you)
+
 2006-06-06  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
 
 	* Namazu.xs: Defined SvPV_nolen if it is not defined.

Modified: Search-Namazu/branches/0.96/Search-Namazu/Namazu.xs
===================================================================
--- Search-Namazu/branches/0.96/Search-Namazu/Namazu.xs	2006-06-09 05:43:51 UTC (rev 267)
+++ Search-Namazu/branches/0.96/Search-Namazu/Namazu.xs	2006-06-09 05:48:57 UTC (rev 268)
@@ -195,22 +195,24 @@
 
 	PPCODE:
 		char *qstr;
+                char buffer[BUFSIZE];
 		char cqstr[BUFSIZE * 2];
 		AV *retar;
 		int i;
 
 		qstr = SvPV(query, PL_na);
-		nmz_codeconv_query(qstr);
-		strcpy(cqstr, qstr);
+                strncpy(buffer, qstr, BUFSIZE);
+                buffer[BUFSIZE - 1] = '\0';
+		nmz_codeconv_query(buffer);
+		strcpy(cqstr, buffer);
 		retar = call_search_main_c(cqstr, maxget);
 #if ! defined(PERL_VERSION) || (PERL_VERSION == 6 && PERL_SUBVERSION == 0)
 		{ /* workaround for only one result */
-			SV *ohlist = perl_eval_pv("new Search::Namazu::Result", TRUE);
-			XPUSHs(ohlist);
+                        SPAGAIN;
 		}
 #endif /* PERL_VERSION */
 		while (av_len(retar) >= 0) {
-			XPUSHs(av_pop(retar));
+			XPUSHs(av_shift(retar));
 		}
 		nmz_free_internal();
 
@@ -221,13 +223,16 @@
 
 	CODE:
 		char *qstr;
+                char buffer[BUFSIZE];
 		char cqstr[BUFSIZE * 2];
 		AV *retar;
 		int i;
 
 		qstr = SvPV(query, PL_na);
-		nmz_codeconv_query(qstr);
-		strcpy(cqstr, qstr);
+                strncpy(buffer, qstr, BUFSIZE);
+                buffer[BUFSIZE - 1] = '\0';
+                nmz_codeconv_query(buffer);
+                strcpy(cqstr, buffer);
 		retar = call_search_main_c(cqstr, maxget);
 		nmz_free_internal();
 		RETVAL = newRV_inc((SV*) retar);
@@ -242,6 +247,7 @@
 
 	CODE:
 		char *qstr;
+                char buffer[BUFSIZE];
 		char cqstr[BUFSIZE * 2];
 		AV *retar;
 		AV *fields;
@@ -249,8 +255,10 @@
 
 		fields = (AV *) SvRV(fieldref);
 		qstr = SvPV(query, PL_na);
-		nmz_codeconv_query(qstr);
-		strcpy(cqstr, qstr);
+                strncpy(buffer, qstr, BUFSIZE);
+                buffer[BUFSIZE - 1] = '\0';
+                nmz_codeconv_query(buffer);
+                strcpy(cqstr, buffer);
 		retar = call_search_main_fields_c(cqstr, maxget, fields);
 		nmz_free_internal();
 		RETVAL = newRV_inc((SV*) retar);




Namazu-cvs メーリングリストの案内