Fix some memory leaks. Fix double destruction of classes. Add some input checks on the environment reader
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2465
This commit is contained in:
parent
6b7b66c0ec
commit
0e9168b556
2 changed files with 21 additions and 8 deletions
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: setup.h,v 1.20 2005-04-21 19:53:40 qbix79 Exp $ */
|
||||
/* $Id: setup.h,v 1.21 2006-01-30 19:37:48 qbix79 Exp $ */
|
||||
|
||||
#ifndef DOSBOX_SETUP_H
|
||||
#define DOSBOX_SETUP_H
|
||||
|
@ -139,7 +139,7 @@ private:
|
|||
std::list<Function_wrapper> destroyfunctions;
|
||||
std::string sectionname;
|
||||
public:
|
||||
Section(const char* _sectionname) { sectionname=_sectionname; }
|
||||
Section(const char* _sectionname):sectionname(_sectionname) { }
|
||||
|
||||
void AddInitFunction(SectionFunction func,bool canchange=false) {initfunctions.push_back(Function_wrapper(func,canchange));}
|
||||
void AddDestroyFunction(SectionFunction func,bool canchange=false) {destroyfunctions.push_front(Function_wrapper(func,canchange));}
|
||||
|
@ -148,9 +148,9 @@ public:
|
|||
const char* GetName() {return sectionname.c_str();}
|
||||
|
||||
virtual char* GetPropValue(const char* _property)=0;
|
||||
virtual void HandleInputline(char * _line){}
|
||||
virtual void PrintData(FILE* outfile) {}
|
||||
virtual ~Section(){ExecuteDestroy(true); }
|
||||
virtual void HandleInputline(char * _line)=0;
|
||||
virtual void PrintData(FILE* outfile)=0;
|
||||
virtual ~Section() { /*Children must call executedestroy ! */}
|
||||
};
|
||||
|
||||
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
void PrintData(FILE* outfile);
|
||||
virtual char* GetPropValue(const char* _property);
|
||||
//ExecuteDestroy should be here else the destroy functions use destroyed properties
|
||||
virtual ~Section_prop(){ExecuteDestroy(true);}
|
||||
virtual ~Section_prop();
|
||||
};
|
||||
|
||||
class Section_line: public Section{
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* $Id: setup.cpp,v 1.31 2005-07-24 19:04:11 qbix79 Exp $ */
|
||||
/* $Id: setup.cpp,v 1.32 2006-01-30 19:37:49 qbix79 Exp $ */
|
||||
|
||||
#include "dosbox.h"
|
||||
#include "cross.h"
|
||||
|
@ -229,6 +229,15 @@ Section_prop* Config::AddSection_prop(const char* _name,void (*_initfunction)(Se
|
|||
return blah;
|
||||
}
|
||||
|
||||
Section_prop::~Section_prop() {
|
||||
//ExecuteDestroy should be here else the destroy functions use destroyed properties
|
||||
ExecuteDestroy(true);
|
||||
/* Delete properties themself (properties stores the pointer of a prop */
|
||||
for(it prop = properties.begin(); prop != properties.end(); prop++)
|
||||
delete (*prop);
|
||||
}
|
||||
|
||||
|
||||
Section_line* Config::AddSection_line(const char* _name,void (*_initfunction)(Section*)){
|
||||
Section_line* blah = new Section_line(_name);
|
||||
blah->AddInitFunction(_initfunction);
|
||||
|
@ -341,10 +350,14 @@ void Config::ParseEnv(char ** envp) {
|
|||
if(strncasecmp(copy,"DOSBOX_",7))
|
||||
continue;
|
||||
char* sec_name = ©[7];
|
||||
if(!(*sec_name))
|
||||
continue;
|
||||
char* prop_name = strrchr(sec_name,'_');
|
||||
if(!prop_name || !(*prop_name))
|
||||
continue;
|
||||
*prop_name++=0;
|
||||
Section* sect = GetSection(sec_name);
|
||||
if(!sect)
|
||||
if(!sect)
|
||||
continue;
|
||||
sect->HandleInputline(prop_name);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue