Page MenuHomePhabricator

GetFileExtensions return pointer to local variable
Closed, ResolvedPublic

Description

On Fri, 2009-11-20 at 13:47 +0100, eduard fried wrote on mitk-users:

The class method mitk::CoreObjectFactory::GetFileExtensions() returns a
const char pointer from the string c_str() method. The string object is
created in this method and also destroyed when the program leaves the
method's scope. Consequently the pointer becomes invalid. As a result
the FileOpen dialog doesn't work, because it filter with a bogus string,
at least in the Debug version. The Release version filters with (*.*),
which works but is still wrong.

The GetSaveFileExtensions is broken in the same way.

This bug occurs in the latest SVN revision 20418 (introduced in rev.

  1. on Windows XP with MS Visual Studio 2008.

Event Timeline

Bug is fixed. Strings are not created locally but within class scope.

[SVN revision 20643]
FIX (#3065): add diffusion file extensions