Skip to content

Commit a683c79

Browse files
Masterlvngjplevyak
andauthored
fix sendLocalResponse (#37)
Co-authored-by: John Plevyak <[email protected]>
1 parent aea22d7 commit a683c79

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

proxy_wasm_api.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ template <typename Pairs> void exportPairs(const Pairs &pairs, const char **ptr,
172172
char *buffer = static_cast<char *>(::malloc(size));
173173
marshalPairs(pairs, buffer);
174174
*size_ptr = size;
175+
*ptr = buffer;
175176
}
176177

177178
struct PairHash {
@@ -609,9 +610,11 @@ inline WasmResult sendLocalResponse(uint32_t response_code, std::string_view res
609610
const char *ptr = nullptr;
610611
size_t size = 0;
611612
exportPairs(additional_response_headers, &ptr, &size);
612-
return proxy_send_local_response(response_code, response_code_details.data(),
613-
response_code_details.size(), body.data(), body.size(), ptr,
614-
size, static_cast<uint32_t>(grpc_status));
613+
WasmResult result = proxy_send_local_response(
614+
response_code, response_code_details.data(), response_code_details.size(), body.data(),
615+
body.size(), ptr, size, static_cast<uint32_t>(grpc_status));
616+
::free(const_cast<char *>(ptr));
617+
return result;
615618
}
616619

617620
// SharedData

0 commit comments

Comments
 (0)