deploy-stub: Fix memory leaks

This commit is contained in:
Mitchell Stokes 2017-01-28 23:35:00 -08:00
parent b8ee352ebb
commit efd25e98a5
1 changed files with 14 additions and 3 deletions

View File

@ -158,6 +158,7 @@ int main(int argc, char *argv[]) {
#endif
struct _frozen *_PyImport_FrozenModules;
unsigned int listoff, modsoff, fsize, modsize, listsize, nummods, modidx;
int retval;
FILE *runtime;
#ifdef _WIN32
@ -210,15 +211,25 @@ int main(int argc, char *argv[]) {
moddef->size = codesize;
}
fclose(runtime);
// Uncomment this to print out the read in module list
//for (unsigned int modidx = 0; modidx < nummods + 1; ++modidx) {
//for (modidx = 0; modidx < nummods; ++modidx) {
// struct _frozen *moddef = &_PyImport_FrozenModules[modidx];
// printf("MOD: %s %p %d\n", moddef->name, (void*)moddef->code, moddef->size);
//}
fclose(runtime);
// Run frozen application
PyImport_FrozenModules = _PyImport_FrozenModules;
return Py_FrozenMain(argc, argv);
retval = Py_FrozenMain(argc, argv);
// Free resources
free(modblob);
for (modidx = 0; modidx < nummods; ++modidx) {
struct _frozen *moddef = &_PyImport_FrozenModules[modidx];
free((void*)moddef->name);
}
free(_PyImport_FrozenModules);
}
#ifdef WIN_UNICODE