The bug csv01.test hangs on powerpc32 and powerpc64
(both are 'char' == 'unsigned char' platforms)

Hangup happens in

    static int csvtabNext(sqlite3_vtab_cursor *cur){
        ...
        if( z==0 || pCur->rdr.cTerm==EOF ){

Here 'pCur->rdr.cTerm' is of type 'char' (holds truncated EOF)
while EOF constant is (int)(-1).

On 'signed char' platforms both arguments sign-extend to 'int'
before comparison and test "works". But ont on 'unsigned char'
platforms where comparison is '0xff == -1'.

Workaround by trunacting EOF constant down to 'char' size.
Not an ideal fix but makes EOF handling more consistent.

Reported-by: Matt Turner
Bug: https://bugs.gentoo.org/630698
Signed-off-by: Sergei Trofimovich <sly...@gentoo.org>
---
 ext/misc/csv.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ext/misc/csv.c b/ext/misc/csv.c
index 6d99634..1bd9888 100644
--- a/ext/misc/csv.c
+++ b/ext/misc/csv.c
@@ -686,7 +686,13 @@ static int csvtabNext(sqlite3_vtab_cursor *cur){
     pCur->aLen[i] = 0;
     i++;
   }
-  if( z==0 || pCur->rdr.cTerm==EOF ){
+  /*
+   * HACK: truncate EOF to 'char' to make code
+   * work equally (bad) on systems with signed
+   * and unsigned char. Other wise platforms
+   * with unsigned char loop indefinitely here.
+   */
+  if( z==0 || pCur->rdr.cTerm==(char)EOF ){
     pCur->iRowid = -1;
   }else{
     pCur->iRowid++;
-- 
2.14.1

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to