Fix leak memory leak in Dart_GetObfuscationMap.

TEST=ci (fixes an existing test failure).

Bug:51224
Change-Id: I73e6f954f3c36a8675c94a919964b8403abc1498
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280254
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index e136bef..5a5a47b 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -55,6 +55,7 @@
 #include "vm/thread_registry.h"
 #include "vm/uri.h"
 #include "vm/version.h"
+#include "vm/zone_text_buffer.h"
 
 #if !defined(DART_PRECOMPILED_RUNTIME)
 #include "vm/compiler/aot/precompiler.h"
@@ -7013,7 +7014,7 @@
 
   // Note: can't use JSONStream in PRODUCT builds.
   const intptr_t kInitialBufferSize = 1 * MB;
-  TextBuffer text_buffer(kInitialBufferSize);
+  ZoneTextBuffer text_buffer(Api::TopScope(T)->zone(), kInitialBufferSize);
 
   text_buffer.AddChar('[');
   if (isolate_group->obfuscation_map() != nullptr) {
@@ -7029,7 +7030,7 @@
   text_buffer.AddChar(']');
 
   *buffer_length = text_buffer.length();
-  *reinterpret_cast<char**>(buffer) = text_buffer.Steal();
+  *reinterpret_cast<char**>(buffer) = text_buffer.buffer();
   return Api::Success();
 #endif
 }