From 63ed60f0483523522067d098abb6044ab6b99e27 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 13 Apr 2017 12:45:18 -0700 Subject: [PATCH] using grpc_base64_decode_with_len to simplify code --- src/core/lib/channel/http_server_filter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index 45dcc26f9a3..ebcde5315fe 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -228,8 +228,6 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, if (offset < path_length) { grpc_slice query_slice = grpc_slice_sub(path_slice, offset + 1, path_length); - /* add a trailing '\0' before decoding */ - const char *b64_data = grpc_slice_to_c_string(query_slice); /* substitute path metadata with just the path (not query) */ grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices( @@ -240,12 +238,14 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, /* decode payload from query and add to the slice buffer to be returned */ const int k_url_safe = 1; - grpc_slice_buffer_add(&calld->read_slice_buffer, - grpc_base64_decode(exec_ctx, b64_data, k_url_safe)); + grpc_slice_buffer_add( + &calld->read_slice_buffer, + grpc_base64_decode_with_len( + exec_ctx, (const char *)GRPC_SLICE_START_PTR(query_slice), + GRPC_SLICE_LENGTH(query_slice), k_url_safe)); grpc_slice_buffer_stream_init(&calld->read_stream, &calld->read_slice_buffer, 0); calld->seen_path_with_query = true; - gpr_free((void *)b64_data); grpc_slice_unref_internal(exec_ctx, query_slice); } else { gpr_log(GPR_ERROR, "GET request without QUERY");