]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
std_sstream.h (setbuf): Check __n >= 0.
authorPaolo Carlini <pcarlini@unitus.it>
Wed, 18 Jun 2003 19:13:18 +0000 (21:13 +0200)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 18 Jun 2003 19:13:18 +0000 (19:13 +0000)
2003-06-18  Paolo Carlini  <pcarlini@unitus.it>
    Benjamin Kosnik  <bkoz@redhat.com>

* include/std/std_sstream.h (setbuf): Check __n >= 0.
* include/bits/fstream.tcc (setbuf): Tweak.

Co-Authored-By: Benjamin Kosnik <bkoz@redhat.com>
From-SVN: r68163

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/std/std_sstream.h

index fad6a0868edf91db2dffe99df121ea7eafb27d32..ac0426e9f80ac1bfd166d3bc491393fd867a8572 100644 (file)
@@ -1,3 +1,9 @@
+2003-06-18  Paolo Carlini  <pcarlini@unitus.it>
+            Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/std/std_sstream.h (setbuf): Check __n >= 0.
+       * include/bits/fstream.tcc (setbuf): Tweak.
+
 2003-06-18  Paolo Carlini  <pcarlini@unitus.it>
 
        * include/bits/sstream.tcc (seekoff): We can't seek beyond
index c0ef882422af439ce49f5c31aca94dc462ab3da8..13275882c47c87e548906670eb90c78e561713d7 100644 (file)
@@ -429,7 +429,7 @@ namespace std
     {
       if (!this->is_open() && __s == 0 && __n == 0)
        this->_M_buf_size = 1;
-      else if (__s && __n >= 1)
+      else if (__s && __n > 0)
        {
          // This is implementation-defined behavior, and assumes that
          // an external char_type array of length __n exists and has
index ca7b1e5484b81e68452b8e28dc7d34c49540a358..a720d3569ff753f655c212fb967107c2a0ab3d99 100644 (file)
@@ -208,12 +208,12 @@ namespace std
       virtual __streambuf_type*
       setbuf(char_type* __s, streamsize __n)
       {
-       if (__s && __n)
+       if (__s && __n >= 0)
          {
            // This is implementation-defined behavior, and assumes
-           // that an external char_type array of length (__s + __n)
-           // exists and has been pre-allocated. If this is not the
-           // case, things will quickly blow up.
+           // that an external char_type array of length __n exists
+           // and has been pre-allocated. If this is not the case,
+           // things will quickly blow up.
            
            // Step 1: Destroy the current internal array.
            _M_string = __string_type(__s, __n);