[Coin-discuss] coin2.5.0 - bug on loading gzipped/bzipped vrml files

Bastian Schmitz bastian.schmitz at udo.edu
Tue Jun 10 01:50:50 EDT 2008


hi list,

when loading gzipped/bzipped files the return value of the functions

size_t SoInput_GZMemBufferReader::readBuffer(char * buffer, const size_t 
readlen)
size_t SoInput_BZ2FileReader::readBuffer(char * buf, const size_t readlen)
size_t SoInput_GZFileReader::readBuffer(char * buf, const size_t readlen)

is "-1" when reaching the end of the stream, although the value should be 
unsigned (size_t). 
This leads to messages like this and/or segmentation faults:

Coin read error: Erroneous character(s) after end of scenegraph: "4". This 
message will only be shown once for this file, but more errors might be 
present

I suppose returning a zero is more appropriate.

cheers,
bastian



diff -rub /tmp/Coin-2.5.0.orig/src/io/SoInput_Reader.cpp /tmp/Coin-2.5.0/src/io/SoInput_Reader.cpp
--- /tmp/Coin-2.5.0/src/io/SoInput_Reader.cpp   2007-10-01 03:23:04.000000000 
+0200
+++ /root/build/Coin-2.5.0/src/io/SoInput_Reader.cpp    2008-06-10 
03:35:08.000000000 +0200
@@ -295,7 +295,8 @@
 {
   // FIXME: about the cast; see note about the call to cc_gzm_open()
   // above. 20050525 mortene.
-  return cc_gzm_read(this->gzmfile, buffer, (uint32_t)readlen);
+  int ret = cc_gzm_read(this->gzmfile, buffer, (uint32_t)readlen);
+  return (ret > 0) ? ret : 0;
 }

 //
@@ -325,7 +326,8 @@
 {
   // FIXME: about the cast; see note about the call to cc_gzm_open()
   // above. 20050525 mortene.
-  return cc_zlibglue_gzread(this->gzfp, (void*) buf, (uint32_t)readlen);
+  int ret = cc_zlibglue_gzread(this->gzfp, (void*) buf, (uint32_t)readlen);
+  return (ret > 0) ? ret : 0;
 }

 const SbString &
@@ -369,7 +371,7 @@
   int ret = cc_bzglue_BZ2_bzRead(&bzerror, this->bzfp,
                                  buf, (uint32_t)readlen);
   if ((bzerror != BZ_OK) && (bzerror != BZ_STREAM_END)) {
-    ret = -1;
+    ret = 0;
     cc_bzglue_BZ2_bzReadClose(&bzerror, this->bzfp);
     this->bzfp = NULL;
   }



More information about the Coin-discuss mailing list