]> granicus.if.org Git - apache/commitdiff
expand and err-check...
authorJim Jagielski <jim@apache.org>
Wed, 20 Jan 2016 17:54:38 +0000 (17:54 +0000)
committerJim Jagielski <jim@apache.org>
Wed, 20 Jan 2016 17:54:38 +0000 (17:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1725766 13f79535-47bb-0310-9956-ffa450edef68

server/util_expr_eval.c

index 4db48d3966e8065ef3546c027cb7bfccd592ba6a..2a995e551b5710e4bcdaf65bf43412becb093a44 100644 (file)
@@ -1065,10 +1065,11 @@ static const char *kb_func(ap_expr_eval_ctx_t *ctx, const void *data,
     if (rv != APR_SUCCESS || len == 0)
         return "";
 
-    buf = apr_palloc(ctx->r->pool, len);
-    apr_brigade_flatten(ctx->r->kept_body, buf, &len);
-    if (len)
-        buf[len-1] = '\0'; /* ensure */
+    buf = apr_palloc(ctx->r->pool, len+1);
+    rv = apr_brigade_flatten(ctx->r->kept_body, buf, &len);
+    if (rv != APR_SUCCESS)
+        return "";
+    buf[len] = '\0'; /* ensure */
     return (const char*)buf;
 }