Skip to content

Commit 4400940

Browse files
committed
browser-dlgprs: fix mistake in class scope and memory deallocation
1 parent d1528b3 commit 4400940

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

bld/browser/dlgprs/cpp/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*
33
* Open Watcom Project
44
*
5+
* Copyright (c) 2026 The Open Watcom Contributors. All Rights Reserved.
56
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
67
*
78
* ========================================================================
@@ -54,10 +55,9 @@ int main( int argc, char * argv[] ) {
5455
if( CurrDialog != NULL ) {
5556
BindingParser bndparse( argv[2] );
5657
bndparse.yyparse();
57-
}
58-
59-
if( CurrDialog != NULL && CurrBinding != NULL ) {
60-
CurrBinding->bind( CurrDialog, argv[3], argv[4] );
58+
if( CurrBinding != NULL ) {
59+
CurrBinding->bind( CurrDialog, argv[3], argv[4] );
60+
}
6161
}
6262

6363
} catch( FileExcept oops ) {

bld/browser/dlgprs/cpp/scanner.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*
33
* Open Watcom Project
44
*
5+
* Copyright (c) 2026 The Open Watcom Contributors. All Rights Reserved.
56
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
67
*
78
* ========================================================================
@@ -42,6 +43,14 @@
4243
const char * const Scanner::_SpecialCharacters = ",{}|:()@#;";
4344

4445

46+
static void my_clear( std::vector<char*> *vec )
47+
{
48+
for (size_t i = 0; i < vec->size(); ++i) {
49+
delete[] (*vec)[i];
50+
}
51+
vec->clear();
52+
}
53+
4554
Scanner::Scanner( const char * fileName, short t_string, short t_number, short t_ident, const TokenStruct *tokens, int tokcnt )
4655
//-----------------------------------------------------------------------------------------------------------------------------
4756
{
@@ -62,7 +71,9 @@ Scanner::Scanner( const char * fileName, short t_string, short t_number, short t
6271
Scanner::~Scanner()
6372
//-----------------
6473
{
74+
my_clear( _identifiers );
6575
delete _identifiers;
76+
my_clear( _strings );
6677
delete _strings;
6778
delete _file;
6879
}
@@ -223,7 +234,7 @@ void Scanner::readQuotedString( YYSTYPE & lval )
223234

224235
buffer[bufPos] = '\0';
225236

226-
dupStr = new char [strlen( buffer ) + 1];
237+
dupStr = new char[strlen( buffer ) + 1];
227238
strcpy( dupStr, buffer );
228239

229240
lval = (YYSTYPE)_strings->size();
@@ -310,7 +321,7 @@ short Scanner::tokenValue( const char * tok, YYSTYPE & lval )
310321
if( res ) {
311322
return res->token;
312323
} else {
313-
dupStr = new char [strlen( tok ) + 1];
324+
dupStr = new char[strlen( tok ) + 1];
314325
strcpy( dupStr, tok );
315326

316327
lval = (YYSTYPE)_identifiers->size();
@@ -319,4 +330,3 @@ short Scanner::tokenValue( const char * tok, YYSTYPE & lval )
319330
return _T_Ident;
320331
}
321332
}
322-

0 commit comments

Comments
 (0)