Revision: 2520
Author: [email protected]
Date: Wed Jul 22 03:23:19 2009
Log: Fix two deallocation bugs identified by Coverity Prevent.

1. The tables array allocated in the CompilationSubCache constructor
    was never deallocated.  Fixed by adding destructor.

2. The buffer allocated in one of the constructors of the
    NoAllocationStringAllocator was never deallocated.  It seems that
    this class sometimes owns the buffer (if it allocated one itself)
    and sometimes doesn't (if it was passed one).  Simple fix is to
    remove the offending constructor which was never used anyway.

Review URL: http://codereview.chromium.org/155917
http://code.google.com/p/v8/source/detail?r=2520

Modified:
  /branches/bleeding_edge/src/compilation-cache.cc
  /branches/bleeding_edge/src/string-stream.cc
  /branches/bleeding_edge/src/string-stream.h

=======================================
--- /branches/bleeding_edge/src/compilation-cache.cc    Tue Jul 14 15:38:06  
2009
+++ /branches/bleeding_edge/src/compilation-cache.cc    Wed Jul 22 03:23:19  
2009
@@ -62,6 +62,8 @@
    explicit CompilationSubCache(int generations): generations_(generations)  
{
      tables_ = NewArray<Object*>(generations);
    }
+
+  ~CompilationSubCache() { DeleteArray(tables_); }

    // Get the compilation cache tables for a specific generation.
    Handle<CompilationCacheTable> GetTable(int generation);
=======================================
--- /branches/bleeding_edge/src/string-stream.cc        Fri Jul 10 12:25:18 2009
+++ /branches/bleeding_edge/src/string-stream.cc        Wed Jul 22 03:23:19 2009
@@ -42,12 +42,6 @@
    space_ = NewArray<char>(bytes);
    return space_;
  }
-
-
-NoAllocationStringAllocator::NoAllocationStringAllocator(unsigned bytes) {
-  size_ = bytes;
-  space_ = NewArray<char>(bytes);
-}


  NoAllocationStringAllocator::NoAllocationStringAllocator(char* memory,
=======================================
--- /branches/bleeding_edge/src/string-stream.h Mon May 25 03:05:56 2009
+++ /branches/bleeding_edge/src/string-stream.h Wed Jul 22 03:23:19 2009
@@ -57,11 +57,10 @@


  // Allocator for use when no new c++ heap allocation is allowed.
-// Allocates all space up front and does no allocation while building
-// message.
+// Given a preallocated buffer up front and does no allocation while
+// building message.
  class NoAllocationStringAllocator: public StringAllocator {
   public:
-  explicit NoAllocationStringAllocator(unsigned bytes);
    NoAllocationStringAllocator(char* memory, unsigned size);
    char* allocate(unsigned bytes) { return space_; }
    char* grow(unsigned* bytes);

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to