These appear in opj2dat.cpp.
Plus, the filename allocated data is freed, so this code leaks.
Suggested fix:
Since this is C++, we should be avoiding clunky old calls like asprintf. Instead, we can simply use stringstream, ie the following code will work:
~~~~~
std::ostringstream os;
os<<argv[1]<<"."<<s+1<<".dat";
printf("saved to %s\n",os.str().c_str());
if((out=fopen(os.str().c_str(),"w")) == NULL ) {
printf("Could not open %s",os.str().c_str());
return -1;
}
~~~~~~
Also I question the use of basename on Windows. If this was argv[0], I might understand, as argv[0] will have an extra .exe on Windows, but argv[1] should be treated identically between the two systems.
If basename is really needed, then boost::filesystem::path::stem will provide an acceptable alternative.