This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 7f94014c9380bb8f505f2fce6b704b8f2e6edb2e
Author: Kit Chan <kic...@apache.org>
AuthorDate: Sun Jun 16 11:41:35 2024 -0700

    Properly handle string return from function (#11442)
    
    * Properly handle string return from function
    
    * Update ats_context.h
    
    * Update ats_context.h
    
    * Update ats_context.h
    
    (cherry picked from commit 4704ee494572305dbfdb5edddc1495b8a0c88d4c)
---
 plugins/experimental/wasm/ats_context.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/plugins/experimental/wasm/ats_context.h 
b/plugins/experimental/wasm/ats_context.h
index 0574b42ec4..094a654c25 100644
--- a/plugins/experimental/wasm/ats_context.h
+++ b/plugins/experimental/wasm/ats_context.h
@@ -180,10 +180,10 @@ public:
     return this;
   }
 
-  std::string
-  get()
+  const char *
+  getDataStrPtr()
   {
-    return owned_data_str_;
+    return owned_data_str_.c_str();
   }
 
 private:
@@ -276,9 +276,12 @@ public:
   const char *
   getTransformResult(size_t *body_size)
   {
-    std::string s = transform_result_.get();
-    *body_size    = s.size();
-    return s.c_str();
+    if (body_size != nullptr) {
+      *body_size = transform_result_.size();
+      return transform_result_.getDataStrPtr();
+    } else {
+      return nullptr;
+    }
   }
 
   // Metrics

Reply via email to