[svn] commit: r1208 - /trunk/src/lib/cc/session.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Mar 8 18:15:03 UTC 2010


Author: jinmei
Date: Mon Mar  8 18:15:02 2010
New Revision: 1208

Log:
fixed exception unsafeness bug

Modified:
    trunk/src/lib/cc/session.cc

Modified: trunk/src/lib/cc/session.cc
==============================================================================
--- trunk/src/lib/cc/session.cc (original)
+++ trunk/src/lib/cc/session.cc Mon Mar  8 18:15:02 2010
@@ -157,17 +157,17 @@
     if (header_length != length) {
         throw SessionError("Received non-empty body where only a header expected");
     }
-    
-    char *buffer = new char[length];
-    ret = read(sock, buffer, length);
-    if (ret != length)
-        throw SessionError("Short read");
-
-    std::string wire = std::string(buffer, length);
-    delete [] buffer;
+
+    std::vector<char> buffer(length);
+    ret = read(sock, &buffer[0], length);
+    if (ret != length) {
+        throw SessionError("Short read");
+    }
+
+    std::string wire = std::string(&buffer[0], length);
 
     std::stringstream wire_stream;
-    wire_stream <<wire;
+    wire_stream << wire;
 
     msg = Element::fromWire(wire_stream, length);
 




More information about the bind10-changes mailing list