Skip to content

Commit

Permalink
tracer: Handle bad address input in the memory view
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Oct 6, 2024
1 parent c3f97b5 commit 33f9557
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apps/tracer/src/MemoryView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export default function MemoryView({ address, onSelectAddress }: MemoryViewProps
}, [address]);

const adjustAddress = useCallback((delta: number) => {
const newAddress = BigInt(addressInputRef.current!.value) + BigInt(delta);
let newAddress: bigint;
try {
newAddress = BigInt(addressInputRef.current!.value) + BigInt(delta);
} catch (e) {
return;
}
onSelectAddress(newAddress);
}, [onSelectAddress]);

Expand All @@ -71,7 +76,7 @@ export default function MemoryView({ address, onSelectAddress }: MemoryViewProps
onKeyDown={e => {
if (e.key === "Enter") {
e.preventDefault();
onSelectAddress(BigInt(addressInputRef.current!.value));
adjustAddress(0);
}
}}
placeholder="Memory address…"
Expand Down

0 comments on commit 33f9557

Please sign in to comment.