- val.psz_string = (char*)path.c_str();
- text.psz_string = (char*)name.substr(0, name.size() - 4).c_str();
+ string shortname = name.substr( 0, name.size() - 4 );
+ val.psz_string = new char[path.size() + 1];
+ text.psz_string = new char[shortname.size() + 1];
+ strcpy( val.psz_string, path.c_str() );
+ strcpy( text.psz_string, shortname.c_str() );