Fix memory leak of and use without initialization.

Arena allocator's empty arena needs to be released in a destructor, this
removes the neeed for Reset.
The DataflowIterator needs to clear changed_ upon construction to avoid use
without initialization.

Change-Id: I56e3cb8c3e06c08ab0ff42447bd6e05792fc70af
diff --git a/src/compiler/dex/arena_allocator.cc b/src/compiler/dex/arena_allocator.cc
index 2db8445..7f1bfb3 100644
--- a/src/compiler/dex/arena_allocator.cc
+++ b/src/compiler/dex/arena_allocator.cc
@@ -50,6 +50,18 @@
   num_arena_blocks_++;
 }
 
+ArenaAllocator::~ArenaAllocator() {
+  // Reclaim all the arena blocks allocated so far.
+  ArenaMemBlock* head = arena_head_;
+  while (head != NULL) {
+    ArenaMemBlock* p = head;
+    head = head->next;
+    free(p);
+  }
+  arena_head_ = current_arena_ = NULL;
+  num_arena_blocks_ = 0;
+}
+
 // Return an arena with no storage for use as a sentinal.
 ArenaAllocator::ArenaMemBlock* ArenaAllocator::EmptyArena() {
   ArenaMemBlock* res = static_cast<ArenaMemBlock*>(malloc(sizeof(ArenaMemBlock)));
@@ -91,19 +103,6 @@
   return ptr;
 }
 
-// Reclaim all the arena blocks allocated so far.
-void ArenaAllocator::ArenaReset() {
-  ArenaMemBlock* head = arena_head_;
-  while (head != NULL) {
-    ArenaMemBlock* p = head;
-    head = head->next;
-    free(p);
-  }
-  // We must always have an arena.  Create a zero-length one.
-  arena_head_ = current_arena_ = EmptyArena();
-  num_arena_blocks_ = 1;
-}
-
 // Dump memory usage stats.
 void ArenaAllocator::DumpMemStats(std::ostream& os) const {
   size_t total = 0;
diff --git a/src/compiler/dex/arena_allocator.h b/src/compiler/dex/arena_allocator.h
index 53d1a1b..26294b6 100644
--- a/src/compiler/dex/arena_allocator.h
+++ b/src/compiler/dex/arena_allocator.h
@@ -47,8 +47,8 @@
     };
 
   ArenaAllocator(size_t default_size = ARENA_DEFAULT_BLOCK_SIZE);
+  ~ArenaAllocator();
   void* NewMem(size_t size, bool zero, ArenaAllocKind kind);
-  void ArenaReset();
   size_t BytesAllocated() {
     return malloc_bytes_;
   }
diff --git a/src/compiler/dex/dataflow_iterator.h b/src/compiler/dex/dataflow_iterator.h
index 7d32dfc..a4b38bd 100644
--- a/src/compiler/dex/dataflow_iterator.h
+++ b/src/compiler/dex/dataflow_iterator.h
@@ -66,7 +66,10 @@
             is_iterative_(is_iterative),
             start_idx_(start_idx),
             end_idx_(end_idx),
-            reverse_(reverse) {}
+            reverse_(reverse),
+            block_id_list_(NULL),
+            idx_(0),
+            changed_(false) {}
 
       virtual BasicBlock* NextBody(bool had_change);
 
diff --git a/src/compiler/dex/frontend.cc b/src/compiler/dex/frontend.cc
index 6f4ee6c..b212e5b 100644
--- a/src/compiler/dex/frontend.cc
+++ b/src/compiler/dex/frontend.cc
@@ -249,8 +249,6 @@
     }
   }
 
-  cu->arena.ArenaReset();
-
   return result;
 }