- Fixed #1743180 fwrite with 0 length crashes on OS X
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 26 Jun 2007 15:17:30 +0000 (15:17 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 26 Jun 2007 15:17:30 +0000 (15:17 +0000)
re2c/CHANGELOG
re2c/htdocs/index.html
re2c/stream_lc.h

index 64c7c0a07db992648504a1b3338968fafaeb9fec..fa5dabf3485c5a6241932e26ee62c7d0a8334910 100644 (file)
@@ -7,6 +7,10 @@ Version 0.13.0 (2007-06-24)
 - Fixed issue with short form of switches and parameter if not first switch.
 - Fixed #1708378 segfault in actions.cc.
 
+Version 0.12.2 (2007-06-26)
+---------------------------
+- Fixed #1743180 fwrite with 0 length crashes on OS X.
+
 Version 0.12.1 (2007-05-23
 ---------------------------
 - Fixed #1711240 problem with '"' and 7F on EBCDIC plattforms.
index dc5e3e4441cf4457c6417e1123c55615bb4ff88d..6363300b5ca86b1bbae3401b8976f2790f041b21 100755 (executable)
@@ -89,6 +89,10 @@ fixes which were incorporated. <a href=
 <li>Fixed issue with short form of switches and parameter if not first switch.</li>
 <li>Fixed #1708378 segfault in actions.cc.</li>
 </ul>
+<h2>2007-06-26: 0.12.2</h2>
+<ul>
+<li>Fixed #1743180 fwrite with 0 length crashes on OS X.</li>
+</ul>
 <h2>2007-05-23: 0.12.1</h2>
 <ul>
 <li>Fixed #1711240 problem with '"' and 7F on EBCDIC plattforms.</li>
index b7505b08d0e2a1fbcb4a174f3b0c78e48a907201..c2895125777a58dba3b42c893643110313f7f3e1 100755 (executable)
@@ -258,7 +258,9 @@ protected:
 
        virtual int sync()
        {
-               fwrite(buffer.c_str(), sizeof(_E), buffer.length(), fp);
+               if (buffer.length() != 0) {
+                       fwrite(buffer.c_str(), sizeof(_E), buffer.length(), fp);
+               }
                buffer.clear();
                return fp == 0
                        || _Tr::eq_int_type(_Tr::eof(), overflow())
@@ -267,7 +269,9 @@ protected:
 
        virtual std::streamsize xsputn(const _E *buf, std::streamsize cnt)
        {
-               fwrite(buffer.c_str(), sizeof(_E), buffer.length(), fp);
+               if (buffer.length() != 0) {
+                       fwrite(buffer.c_str(), sizeof(_E), buffer.length(), fp);
+               }
                buffer.clear();
                /*fline += std::count(buf, buf + cnt, '\n');*/
                for (std::streamsize pos = 0; pos < cnt; ++pos) 
@@ -277,7 +281,11 @@ protected:
                                ++fline;
                        }
                }
-               return fwrite(buf, sizeof(_E), cnt, fp);
+               if (cnt != 0) {
+                       return fwrite(buf, sizeof(_E), cnt, fp);
+               } else {
+                       return 0;
+               }
        }
 
 private: