Skip to content

Commit

Permalink
Merge pull request #5 from passby6someone/main
Browse files Browse the repository at this point in the history
fix MsgSvrID integer overflow
  • Loading branch information
stkevintan authored Sep 24, 2024
2 parents e97d422 + 4e7ecc0 commit 3e580e8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,14 @@ function parseDbField(type: number, content: Uint8Array) {
// self._SQL_TYPES = {1: int, 2: float, 3: lambda x: x.decode("utf-8"), 4: bytes, 5: lambda x: None}
switch (type) {
case 1:
return Number.parseInt(uint8Array2str(content), 10);
const strContent = uint8Array2str(content);

Check failure on line 959 in packages/core/src/lib/client.ts

View workflow job for this annotation

GitHub Actions / main

Unexpected lexical declaration in case block
const bigIntContent = BigInt(strContent);

Check failure on line 960 in packages/core/src/lib/client.ts

View workflow job for this annotation

GitHub Actions / main

Unexpected lexical declaration in case block
if (bigIntContent > Number.MAX_SAFE_INTEGER) {
// bigInt 在JSON.stringify时会出问题,还是返回字符串吧
// TypeError: Do not know how to serialize a BigInt
return strContent;
}
return Number.parseInt(strContent, 10);
case 2:
return Number.parseFloat(uint8Array2str(content));
case 3:
Expand Down

0 comments on commit 3e580e8

Please sign in to comment.