From e2829336cfedb39d23263f75b61ed969c8193534 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 03:34:03 +0100 Subject: fix leak --- src/util/string.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/util/string.h') diff --git a/src/util/string.h b/src/util/string.h index 2268a36..6d44b53 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -54,15 +54,15 @@ struct ARRSTR { template struct __str : public LIST { __str() : LIST() {} - __str( U32 count, const CT* str ) : LIST() { + __str( U32 count, const CT* str ) { this->data = 0; - this->capacity = 0; + this->capacity = this->size = 0; this->reserve( count * 2 ); memcpy( this->data, str, count ); this->size = count; this->data[this->size] = 0; } - __str( const CT* fmt, ... ) : LIST() { + __str( const CT* fmt, ... ) { va_list args; va_start( args, fmt ); va_list args2; @@ -70,7 +70,7 @@ struct __str : public LIST { U32 c = vsnprintf( 0, 0, fmt, args ); va_end( args ); this->data = 0; - this->capacity = 0; + this->capacity = this->size = 0; this->reserve( c * 2 ); vsnprintf( this->data, c + 1, fmt, args2 ); this->data[c] = 0; @@ -165,7 +165,7 @@ struct __str : public LIST { __str& append( const CT* str ) { U32 len; for( len = 0; !!str[len]; ++len ); - if( this->size + len > this->capacity ) + if( this->size + len + 1 > this->capacity ) this->reserve( this->size + len + 1 ); memcpy( this->data + this->size, str, len * sizeof(CT) ); -- cgit v1.2.3