Skip to content

Commit 5463aa0

Browse files
committed
Use non-capturing regex for data to prevent memory exhaustion for long strings (#4741).
1 parent 8b5dfca commit 5463aa0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src.ts/utils/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function _getBytes(value: BytesLike, name?: string, copy?: boolean): Uint8Array
3131
return value;
3232
}
3333

34-
if (typeof(value) === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) {
34+
if (typeof(value) === "string" && value.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
3535
const result = new Uint8Array((value.length - 2) / 2);
3636
let offset = 2;
3737
for (let i = 0; i < result.length; i++) {

0 commit comments

Comments
 (0)