Skip to content

Commit

Permalink
Check for number type or throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
SindreVatnaland committed Jan 11, 2024
1 parent 6960c47 commit da49cef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dolphin-memory-reader",
"version": "0.6.2",
"version": "0.6.3",
"description": "Node module that can read memory from the Dolphin Emulator",
"main": "dist/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export default class DolphinMemory {
read(address: number, byteSize: ByteSize = ByteSize.U8): number {
if (!this.memory) throw new Error("Dolphin memory not initialized");
try {
return this.memoryRead.call(this.memory, address, byteSize);
const value = this.memoryRead.call(this.memory, address, byteSize);
if (typeof value !== "number") throw new Error("Failed to read memory");
return value;
} catch {
throw new Error("Failed to read memory");
}
Expand Down

0 comments on commit da49cef

Please sign in to comment.