From a8f4794e6e8033574ec3005bbde6fecb9942bbcf Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 25 Oct 2020 14:34:06 -0300 Subject: [PATCH] Fix std::string corruption caused by memset a non-POD variable Fixes #4 --- include/CmdLineParams.h | 10 ++++++---- src/main.cpp | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/CmdLineParams.h b/include/CmdLineParams.h index aad9ef7..57b8586 100644 --- a/include/CmdLineParams.h +++ b/include/CmdLineParams.h @@ -26,9 +26,11 @@ namespace Codec struct CmdLineParams { - uint8_t quality; - bool dither; - bool usingRenderDoc; + uint8_t quality; + bool dither; + bool usingRenderDoc; Codec::Codec codec; - std::string filename[2]; + std::string filename[2]; + + CmdLineParams() : quality( 0 ), dither( false ), usingRenderDoc( false ), codec( Codec::etc1 ) {} }; diff --git a/src/main.cpp b/src/main.cpp index a71500d..36b4f95 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -162,7 +162,6 @@ void saveToDisk( T &encoder, const CmdLineParams params ) int main( int nargs, char *const argv[] ) { CmdLineParams params; - memset( ¶ms, 0, sizeof( params ) ); params.quality = 2; if( !parseCmdLine( nargs, argv, params ) )