In PrintCode, keep the debug_name string alive for all uses.
authorjarin <jarin@chromium.org>
Tue, 10 Mar 2015 12:02:45 +0000 (05:02 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 10 Mar 2015 12:02:53 +0000 (12:02 +0000)
BUG=chromium:465645
LOG=n
R=titzer@chromium.org

Review URL: https://codereview.chromium.org/996663002

Cr-Commit-Position: refs/heads/master@{#27099}

src/codegen.cc

index ba32ace..796e39a 100644 (file)
@@ -183,12 +183,14 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
          (info->IsOptimizing() && FLAG_print_opt_code));
   if (print_code) {
     const char* debug_name;
+    SmartArrayPointer<char> debug_name_holder;
     if (info->IsStub()) {
       CodeStub::Major major_key = info->code_stub()->MajorKey();
       debug_name = CodeStub::MajorName(major_key, false);
     } else {
-      debug_name =
-          info->parse_info()->function()->debug_name()->ToCString().get();
+      debug_name_holder =
+          info->parse_info()->function()->debug_name()->ToCString();
+      debug_name = debug_name_holder.get();
     }
 
     CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer());