From b03e4621253ce98b939cbd371a902450b7a1be4c Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 17 Feb 2023 20:31:55 -0600 Subject: [PATCH] bsearch: return NULL without calling compare function if count==0. This is explicitly required in C99 and later. --- stdlib.asm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stdlib.asm b/stdlib.asm index 0c30719..74baece 100644 --- a/stdlib.asm +++ b/stdlib.asm @@ -333,6 +333,10 @@ addr equ 13 address of array element of index test csubroutine (4:key,4:base,4:count,4:size,4:compar),16 + lda count if count is 0 then + ora count+2 + jeq lb5 just return a null pointer + lda compar patch the call address sta >jsl+1 lda compar+1