Skip to content

Commit 0decb0b

Browse files
committed
alloc bigger tx bufs
1 parent 19125db commit 0decb0b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/common.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <common/parser.h>
2020
#include <sstream>
21+
#include <memory>
2122
#include <string>
2223
#include <fmt/core.h>
2324
#include "common.h"
@@ -26,6 +27,7 @@
2627
#include <json/json.h>
2728
#include <app_mode.h>
2829
#include <hexutils.h>
30+
#include <stdlib.h>
2931

3032
std::vector<std::string> dumpUI(parser_context_t *ctx,
3133
uint16_t maxKeyLen,
@@ -131,13 +133,16 @@ void check_testcase(const testcase_t &tc, bool expert_mode) {
131133
parser_context_t ctx = {0};
132134
parser_error_t err = parser_unexpected_error;
133135

134-
uint8_t buffer[10000] = {0};
135-
const uint16_t bufferLen = parseHexString(buffer, sizeof(buffer), tc.blob.c_str());
136+
auto bufferCap = 1<<17; // 132 KiB
137+
std::unique_ptr<uint8_t> buffer{new uint8_t[bufferCap]};
138+
if (buffer == nullptr) { abort(); }
139+
140+
const uint16_t bufferLen = parseHexString(buffer.get(), bufferCap, tc.blob.c_str());
136141

137142
parser_tx_t tx_obj;
138143
memset(&tx_obj, 0, sizeof(tx_obj));
139144

140-
err = parser_parse(&ctx, buffer, bufferLen, &tx_obj);
145+
err = parser_parse(&ctx, buffer.get(), bufferLen, &tx_obj);
141146
ASSERT_EQ(err, parser_ok) << parser_getErrorDescription(err);
142147

143148
err = parser_validate(&ctx);

0 commit comments

Comments
 (0)