From: hgn Date: Wed, 26 Jun 2024 14:55:49 +0000 (+0100) Subject: terrible buffer underflow bug in vg_string X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=0ca31e13cb9edeac6c483dba1537c69f0ceb7eee;p=vg.git terrible buffer underflow bug in vg_string --- diff --git a/submodules/SDL_GameControllerDB b/submodules/SDL_GameControllerDB index 6ed8d05..c5b4df0 160000 --- a/submodules/SDL_GameControllerDB +++ b/submodules/SDL_GameControllerDB @@ -1 +1 @@ -Subproject commit 6ed8d054340ee8a93a684e11360b66cd8a5c168e +Subproject commit c5b4df0e1061175cb11e3ebbf8045178339864a5 diff --git a/submodules/anyascii b/submodules/anyascii index 44e971c..eb5332d 160000 --- a/submodules/anyascii +++ b/submodules/anyascii @@ -1 +1 @@ -Subproject commit 44e971c774d9ec67ca6c1f16c5a476724821ab63 +Subproject commit eb5332d0b5e48d58397e6f27475a18e058330d23 diff --git a/submodules/qoi b/submodules/qoi index b8d77df..dfc056e 160000 --- a/submodules/qoi +++ b/submodules/qoi @@ -1 +1 @@ -Subproject commit b8d77df1e80b652a57f0b7270449b179a6b91f40 +Subproject commit dfc056e813c98d307238d35f7f041a725d699dfc diff --git a/submodules/stb b/submodules/stb index 8b5f1f3..5736b15 160000 --- a/submodules/stb +++ b/submodules/stb @@ -1 +1 @@ -Subproject commit 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55 +Subproject commit 5736b15f7ea0ffb08dd38af21067c314d6a3aae9 diff --git a/vg_build.h b/vg_build.h index be9f098..5fce6f0 100644 --- a/vg_build.h +++ b/vg_build.h @@ -444,7 +444,7 @@ vg_make_app( struct vg_project *proj, vg_strcatf( &components, "%s ", sources ); struct vg_compiler_env denv = *env; - denv.optimization = 3; + //denv.optimization = 3; /* external dependencies */ struct compile_result depencies = diff --git a/vg_string.c b/vg_string.c index f6c7344..61df5fe 100644 --- a/vg_string.c +++ b/vg_string.c @@ -74,9 +74,9 @@ static i32 vg_str_dynamic_grow( vg_str *str ) } } -static void _vg_strcatch( vg_str *str, char c ) +static bool _vg_strcatch( vg_str *str, char c ) { - if( str->i == -1 ) return; + if( str->i == -1 ) return 0; i32 max = vg_str_storage( str ); if( str->i == max ) @@ -87,11 +87,12 @@ static void _vg_strcatch( vg_str *str, char c ) { str->i = -1; str->buffer[ max-1 ] = '\0'; - return; + return 0; } } str->buffer[ str->i ++ ] = c; + return 1; } void vg_strcat( vg_str *str, const char *append ) @@ -102,7 +103,7 @@ void vg_strcat( vg_str *str, const char *append ) append:; char c = append[ i ++ ]; - _vg_strcatch( str, c ); + if( !_vg_strcatch( str, c ) ) return; if( c == '\0' ) {