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

@@ -235,12 +235,22 @@ int main(int argc, char* argv[])
}
PycModule mod;
mod.loadFromFile(argv[1]);
try {
mod.loadFromFile(argv[1]);
} catch (std::exception& ex) {
fprintf(stderr, "Error disassembling %s: %s\n", argv[1], ex.what());
return 1;
}
const char* dispname = strrchr(argv[1], PATHSEP);
dispname = (dispname == NULL) ? argv[1] : dispname + 1;
fprintf(pyc_output, "%s (Python %d.%d%s)\n", dispname, mod.majorVer(), mod.minorVer(),
(mod.majorVer() < 3 && mod.isUnicode()) ? " -U" : "");
output_object(mod.code().cast<PycObject>(), &mod, 0);
try {
output_object(mod.code().cast<PycObject>(), &mod, 0);
} catch (std::exception& ex) {
fprintf(stderr, "Error disassembling %s: %s\n", argv[1], ex.what());
return 1;
}
return 0;
}