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

sorber pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  91bfe21   Fix possibility of NULL assignment to std::string
91bfe21 is described below

commit 91bfe214cc2356ae19b78776815d0344d1a0906d
Author: Phil Sorber <[email protected]>
AuthorDate: Sun Oct 2 18:18:35 2016 -0600

    Fix possibility of NULL assignment to std::string
---
 plugins/header_rewrite/expander.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/plugins/header_rewrite/expander.cc 
b/plugins/header_rewrite/expander.cc
index 22dca9c..c62a7d0 100644
--- a/plugins/header_rewrite/expander.cc
+++ b/plugins/header_rewrite/expander.cc
@@ -67,7 +67,12 @@ VariableExpander::expand(const Resources &res)
       // Protocol of the incoming request
       if (TSHttpTxnPristineUrlGet(res.txnp, &bufp, &url_loc) == TS_SUCCESS) {
         int len;
-        resolved_variable = TSUrlSchemeGet(bufp, url_loc, &len);
+        const char *tmp = TSUrlSchemeGet(bufp, url_loc, &len);
+        if ((tmp != NULL) && (len > 0)) {
+          resolved_variable.assign(tmp, len);
+        } else {
+          resolved_variable.assign("");
+        }
         TSHandleMLocRelease(bufp, TS_NULL_MLOC, url_loc);
       }
     } else if (variable == "%<port>") {

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to