shithub: scc

Download patch

ref: 1de26472868d15174ef01a9655555340234c4dbe
parent: f2750859e3c3be0019fc10890baa96c41be40b68
author: Naveen Narayanan <zerous@simple-cc.org>
date: Fri Oct 1 23:24:29 EDT 2021

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.

--- a/src/libc/arch/amd64/strchr.s
+++ b/src/libc/arch/amd64/strchr.s
@@ -15,6 +15,8 @@
 	leaq	-1(%rdi),%rcx
 	subq	%r8,%rcx
 
+	cmp     %rdi,%rsi       /* set ZF to 0 */
+
 	movq	%r8,%rdi
 	movb	%sil,%al
 	repne