diff --git a/packages/compiler/test/ts7/baselines/order-parity/tests/corpus/8129-brotli-long-param-name.cjs.json b/packages/compiler/test/ts7/baselines/order-parity/tests/corpus/8129-brotli-long-param-name.cjs.json new file mode 100644 index 000000000..33ef96201 --- /dev/null +++ b/packages/compiler/test/ts7/baselines/order-parity/tests/corpus/8129-brotli-long-param-name.cjs.json @@ -0,0 +1,6 @@ +{ + "order": [ + "/tests/corpus/8129-brotli-long-param-name.cjs" + ], + "diags": [] +} diff --git a/packages/runtime/src/scr_brotli.c b/packages/runtime/src/scr_brotli.c index 617b0c60f..f66ecae75 100644 --- a/packages/runtime/src/scr_brotli.c +++ b/packages/runtime/src/scr_brotli.c @@ -161,10 +161,16 @@ static uint32_t scr_brotli_uint32(const ScrDyn *v) { return (uint32_t)m; } +/* ERR_BROTLI_INVALID_PARAM: the whole key, then Node's text. */ static void scr_brotli_invalid_param(const ScrStr *key) { - char message[160]; - int n = snprintf(message, sizeof message, "%.*s is not a valid Brotli parameter", (int)key->len, key->data); - scr_throw_error_msg_code(SCR_ERR_RANGE, message, (size_t)n, "ERR_BROTLI_INVALID_PARAM"); + static const char suffix[] = " is not a valid Brotli parameter"; + size_t len = key->len + sizeof suffix - 1; + char *message = malloc(len); + if (!message) scr_brotli_oom(); + memcpy(message, key->data, key->len); + memcpy(message + key->len, suffix, sizeof suffix - 1); + scr_throw_error_msg_code(SCR_ERR_RANGE, message, len, "ERR_BROTLI_INVALID_PARAM"); + free(message); } /* opts.params: each own key must name a parameter (0..8) once, and each diff --git a/packages/runtime/test/common-symbols.test.ts b/packages/runtime/test/common-symbols.test.ts index 43d4461e6..344bd01d6 100644 --- a/packages/runtime/test/common-symbols.test.ts +++ b/packages/runtime/test/common-symbols.test.ts @@ -38,6 +38,7 @@ async function commonSymbols(label: string, compiler: string[]): Promise