commit 50823e3a5e52629d8eee8980583e1387aeb75d86
parent 0714d6c83087281c17643f2c48ab1568f95f8320
Author: Naveen Narayanan <zerous@simple-cc.org>
Date: Sat, 2 Oct 2021 03:24:29 +0200
libc: Fix bug in strchr.s for amd64
Reset ZF flag after subq instruction as the sub operation sets ZF flag
when the length of string s is 0. This busts the jump logic used
after scan string instruction.
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/libc/arch/amd64/strchr.s b/src/libc/arch/amd64/strchr.s
@@ -15,6 +15,8 @@ strchr:
leaq -1(%rdi),%rcx
subq %r8,%rcx
+ cmp %rdi,%rsi /* set ZF to 0 */
+
movq %r8,%rdi
movb %sil,%al
repne