From 5884cf88d3317500051c8a80b4c94bcdd7ab78e6 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 14 Feb 2021 21:33:41 +0000 Subject: [PATCH] crtlib: fix undefined behaviour when stripping extenstion from empty string --- public/crtlib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/crtlib.c b/public/crtlib.c index 281d11fe..bec512d2 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -858,7 +858,11 @@ void COM_StripExtension( char *path ) { size_t length; - length = Q_strlen( path ) - 1; + length = Q_strlen( path ); + + if( length > 0 ) + length--; + while( length > 0 && path[length] != '.' ) { length--;