From d85c16b52f50095aab181e41d9454b0eab8746c1 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Sun, 3 Apr 2011 11:57:57 +0000 Subject: [PATCH] assimp_cmd: fix possible crash in assimp export if the file can be imported, cosmetic fixes. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@935 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- tools/assimp_cmd/Export.cpp | 9 ++++++--- tools/assimp_cmd/Main.cpp | 16 ++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/assimp_cmd/Export.cpp b/tools/assimp_cmd/Export.cpp index 4f3c9b505..feea039e5 100644 --- a/tools/assimp_cmd/Export.cpp +++ b/tools/assimp_cmd/Export.cpp @@ -128,7 +128,7 @@ int Assimp_Export(const char* const* params, unsigned int num) if (outfi == SIZE_MAX) { // still no match -> failure - printf("assimp export: no output format specified and I failed to guess it"); + printf("assimp export: no output format specified and I failed to guess it\n"); return -23; } } @@ -152,6 +152,9 @@ int Assimp_Export(const char* const* params, unsigned int num) // import the model const aiScene* scene = ImportModel(import,in); + if (!scene) { + return -39; + } // derive the final file name out += "."+outext; @@ -160,9 +163,9 @@ int Assimp_Export(const char* const* params, unsigned int num) if(!ExportModel(scene, import, out,e->id)) { return -25; } - printf("assimp export: wrote output file: %s",out.c_str()); + printf("assimp export: wrote output file: %s\n",out.c_str()); return 0; } #endif // no export - \ No newline at end of file + diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index e4f92ca8f..ebc262041 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -62,14 +62,13 @@ const char* AICMD_MSG_HELP = #ifndef ASSIMP_BUILD_NO_EXPORT " \texport - Export a file to one of the supported output formats\n" " \tlistexport - List all supported export formats\n" -" \tknowexport - Check whether a particular export format is supported\n" " \texportinfo - Show basic information on a specific export format\n" #endif " \textract - Extract embedded texture images\n" " \tdump - Convert models to a binary or textual dump (ASSBIN/ASSXML)\n" " \tcmpdump - Compare dumps created using \'assimp dump -s ...\'\n" " \tversion - Display Assimp version\n" -"\n\n Use \'assimp --help\' for detailed help on a command.\n" +"\n Use \'assimp --help\' for detailed help on a command.\n" ; /*extern*/ Assimp::Importer* globalImporter = NULL; @@ -135,7 +134,7 @@ int main (int argc, char* argv[]) aiString s; imp.GetExtensionList(s); - printf("%s",s.data); + printf("%s\n",s.data); return 0; } @@ -153,29 +152,30 @@ int main (int argc, char* argv[]) } } - printf("%s",s.data); + printf("%s\n",s.data); return 0; } + // assimp exportinfo // stat an export format if (! strcmp(argv[1], "exportinfo")) { aiString s; if (argc<3) { - printf("Expected file format id"); + printf("Expected file format id\n"); return -11; } for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) { const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i); if (!strcmp(e->id,argv[2])) { - printf("%s\n%s\n%s",e->id,e->fileExtension,e->description); + printf("%s\n%s\n%s\n",e->id,e->fileExtension,e->description); return 0; } } - printf("Unknown file format id: %s",argv[2]); + printf("Unknown file format id: \'%s\'\n",argv[2]); return -12; } @@ -195,7 +195,7 @@ int main (int argc, char* argv[]) return -10; } const bool b = imp.IsExtensionSupported(argv[2]); - printf("File extension %s is %sknown",argv[2],(b?"":"not ")); + printf("File extension \'%s\' is %sknown\n",argv[2],(b?"":"not ")); return b?0:-1; }