Skip to content

Commit

Permalink
Fixed changes requested by @srenatus (squash before merge)
Browse files Browse the repository at this point in the history
Fixes open-policy-agent#4140

Signed-off-by: Kristian Svalland <kristian.svalland@gmail.com>
  • Loading branch information
kristiansvalland committed Jan 10, 2022
1 parent a21ddde commit 1c7d15a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions wasm/src/encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <limits.h>

#include "json.h"
#include "malloc.h"
#include "value.h"

static const unsigned char base64_table[65] =
Expand Down Expand Up @@ -334,5 +335,6 @@ opa_value *opa_json_is_valid(opa_value *a)
return opa_boolean(false);
}

opa_free(r);
return opa_boolean(true);
}
4 changes: 2 additions & 2 deletions wasm/tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1790,8 +1790,8 @@ void test_json(void)
{
test("json/marshal", opa_value_compare(opa_json_marshal(opa_string_terminated("string")), opa_string_terminated("\"string\"")) == 0);
test("json/unmarshal", opa_value_compare(opa_json_unmarshal(opa_string_terminated("\"string\"")), opa_string_terminated("string")) == 0);
test("json/is_valid_true", opa_value_compare(opa_json_is_valid(opa_string_terminated("\"string\"")), opa_boolean(true)) == 0);
test("json/is_valid_false", opa_value_compare(opa_json_is_valid(opa_string_terminated("\"string")), opa_boolean(false)) == 0);
test("json/is_valid_true", opa_cast_boolean(opa_json_is_valid(opa_string_terminated("\"string\"")))->v);
test("json/is_valid_false", !opa_cast_boolean(opa_json_is_valid(opa_string_terminated("\"string")))->v);
}

WASM_EXPORT(test_object)
Expand Down

0 comments on commit 1c7d15a

Please sign in to comment.