From bda95a298ae2e21fbab231981f232d0eebd1bedd Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Fri, 31 Dec 2021 12:52:39 -0600 Subject: [PATCH] Fix overflow bug with MD_StringMatchFlag_RightSideSloppy If a is longer than b, then MD_S8Match will check outside of b's bounds. --- source/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/md.c b/source/md.c index 75868ca..d3a2b41 100644 --- a/source/md.c +++ b/source/md.c @@ -958,7 +958,7 @@ MD_S8Match(MD_String8 a, MD_String8 b, MD_MatchFlags flags) if(a.size == b.size || flags & MD_StringMatchFlag_RightSideSloppy) { result = 1; - for(MD_u64 i = 0; i < a.size; i += 1) + for(MD_u64 i = 0; i < a.size && i < b.size; i += 1) { MD_b32 match = (a.str[i] == b.str[i]); if(flags & MD_StringMatchFlag_CaseInsensitive)