Menu

#1 App crash when string in config file more then 15 character

open
nobody
None
5
2009-09-25
2009-09-25
tsong
No

i use libconfig in visual studio 2008 express
my test code is very simple, open test.cfg and read log_property key

I try with 1.32 and 1.4 beta 4
#include <libconfig.h++>
#include <iostream>
#include <exception>

using namespace libconfig;
using namespace std;

int main()
{
Config config;
string tmp_str2;
try{
config.readFile("test.cfg");
}
catch (ParseException &e)
{
printf("failed - %s,line:%d error:=%s\n", e.what(),e.getLine(),e.getError());
return -1;
}
catch (...)
{
printf("failed \n");
return -1;
}

if(config.lookupValue("log_property",tmp_str2))
{
cout << tmp_str2;
}
return 0;
}

My problem is, application will crash if log_property is more then 15 character.
may i know what is the maximum size for string libconfig

it crash in when application end during string destructor is call.
void deallocate(pointer _Ptr, size_type)
{ // deallocate object at _Ptr, ignore size
::operator delete(_Ptr);
}

///////////////////////////////////////////////////////////////////
test.cfg with single line only.
log_property = "12345678901234567890";

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.