crypto: fix DecipherUpdate() memory leak
authorBen Noordhuis <info@bnoordhuis.nl>
Fri, 6 Jul 2012 14:37:03 +0000 (16:37 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Sun, 8 Jul 2012 12:45:55 +0000 (14:45 +0200)
Fix a memory leak in the the code path that deals with partial hex strings.

src/node_crypto.cc

index b09fbbb1dc26f96f27f8e309d2d8f9266a2ec819..8b21825a2bf572caa8b08fba2f869241a63bc425 100644 (file)
@@ -2641,10 +2641,8 @@ class Decipher : public ObjectWrap {
         char* complete_hex = new char[len+2];
         memcpy(complete_hex, &cipher->incomplete_hex, 1);
         memcpy(complete_hex+1, buf, len);
-        if (alloc_buf) {
-          delete [] buf;
-          alloc_buf = false;
-        }
+        if (alloc_buf) delete [] buf;
+        alloc_buf = true;
         buf = complete_hex;
         len += 1;
       }