trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject [trafficserver] branch 8.0.x updated: fix for cpp api Transaction::redirectTo
Date Fri, 31 Aug 2018 16:20:05 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/8.0.x by this push:
     new 6c1af1e  fix for cpp api Transaction::redirectTo
6c1af1e is described below

commit 6c1af1e35670e0b5d26de6c64d8b30c8fb78cd6f
Author: Dan M <daniel.morilha@netlify.com>
AuthorDate: Sun Aug 12 10:02:55 2018 -0700

    fix for cpp api Transaction::redirectTo
    
    addressing code review comments
    
    (cherry picked from commit 538b332a979f548f20a43c9b79cbe435da7cea74)
---
 lib/cppapi/Transaction.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/cppapi/Transaction.cc b/lib/cppapi/Transaction.cc
index 5674c09..287dd8d 100644
--- a/lib/cppapi/Transaction.cc
+++ b/lib/cppapi/Transaction.cc
@@ -397,9 +397,11 @@ Transaction::getCacheStatus()
 void
 Transaction::redirectTo(std::string const &url)
 {
-  std::string s = url;
   // Must re-alloc the string locally because ownership is transferred to the transaction.
-  TSHttpTxnRedirectUrlSet(state_->txn_, s.c_str(), url.length());
+  char * const buffer = static_cast<char *>(TSmalloc(url.size() + 1));
+  memcpy(buffer, url.c_str(), url.size());
+  buffer[url.size()] = '\0';
+  TSHttpTxnRedirectUrlSet(state_->txn_, buffer, url.size());
 }
 
 namespace


Mime
View raw message