Fix several undefined behavior issues identified by @nrathaus.

Fixes #147.
This commit is contained in:
Michael Hansen
2018-01-28 14:33:26 -08:00
parent a9a362254e
commit bf60a5831b
12 changed files with 152 additions and 55 deletions

View File

@@ -15,7 +15,12 @@ int main(int argc, char* argv[])
}
PycModule mod;
mod.loadFromFile(argv[1]);
try {
mod.loadFromFile(argv[1]);
} catch (std::exception& ex) {
fprintf(stderr, "Error loading file %s: %s\n", argv[1], ex.what());
return 1;
}
if (!mod.isValid()) {
fprintf(stderr, "Could not load file %s\n", argv[1]);
return 1;
@@ -25,7 +30,12 @@ int main(int argc, char* argv[])
fputs("# Source Generated with Decompyle++\n", pyc_output);
fprintf(pyc_output, "# File: %s (Python %d.%d%s)\n\n", dispname, mod.majorVer(), mod.minorVer(),
(mod.majorVer() < 3 && mod.isUnicode()) ? " Unicode" : "");
decompyle(mod.code(), &mod);
try {
decompyle(mod.code(), &mod);
} catch (std::exception& ex) {
fprintf(stderr, "Error decompyling %s: %s\n", argv[1], ex.what());
return 1;
}
return 0;
}