Skip to content

Commit

Permalink
proxy: fix for result value buffers
Browse files Browse the repository at this point in the history
wasn't malloc'ing space for a value to copy into a result object.

we still can't copy a value from a result object, which prevents us from
creating new requests from a response or a response from a response, but
that will happen after upstream mcmc fixes.
  • Loading branch information
dormando committed Oct 30, 2024
1 parent e368cd2 commit e887658
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion proxy_mutator.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,10 @@ static int mcp_mut_run(struct mcp_mut_run *run) {
struct mcp_mut_part parts[mut->scount];

// first accumulate the length tally
// FIXME: noticed off-by-one's sometimes.
// maybe add a debug assert to verify the written total (d_pos - etc)
// matches total?
// This isn't critical so long as total is > actual, which it has been
int total = _mcp_mut_run_total(run, parts);
if (total < 0) {
lua_pushboolean(run->L, 0);
Expand Down Expand Up @@ -986,7 +990,9 @@ static int mcp_mut_run(struct mcp_mut_run *run) {
} else {
mcp_resp_t *rs = run->arg;

rs->buf = malloc(total);
// value is inlined in result buffers. future intention to allow more
// complex objects so we can refcount values.
rs->buf = malloc(total + run->vlen);
if (rs->buf == NULL) {
proxy_lua_error(run->L, "mutator: failed to allocate result buffer");
return 0;
Expand Down

0 comments on commit e887658

Please sign in to comment.