atoi: Prevent (unsigned) overflow

This commit is contained in:
2025-07-22 06:45:46 +02:00
parent 53b5314d68
commit d15ed616e9

View File

@@ -150,6 +150,12 @@ atoi:
.calcNum_cnt:
imul r9
mov rdx, -1
sub rdx, r10
cmp rax, rdx
;TODO: Add signed checks
ja .overflow
add r10, rax
dec rdi
inc r8
@@ -159,6 +165,10 @@ atoi:
.wrapup_neg:
neg r10
jmp .quit
.overflow:
xor r10, r10
.quit:
mov rax, r10