diff --git a/tools/pnnx/src/main.cpp b/tools/pnnx/src/main.cpp index 69a0c9ffd..d040508e1 100644 --- a/tools/pnnx/src/main.cpp +++ b/tools/pnnx/src/main.cpp @@ -163,8 +163,9 @@ static bool file_maybe_numpy(const std::string& path) return false; } - char signature[6]; + char signature[7]; fread(signature, sizeof(char), 6, fp); + signature[6] = '\0'; fclose(fp); @@ -180,7 +181,7 @@ static void prase_numpy_file_list(char* s, std::vector >& s { if (!file_maybe_numpy(s)) { - fprintf(stderr, "%s is not a vaild numpy file", s); + fprintf(stderr, "%s is not a vaild numpy file", s.c_str()); return ; } pnnx::prase_numpy_file(s.c_str(), shapes, types, contents); diff --git a/tools/pnnx/src/utils.cpp b/tools/pnnx/src/utils.cpp index 6824fc7f8..ba860fc65 100644 --- a/tools/pnnx/src/utils.cpp +++ b/tools/pnnx/src/utils.cpp @@ -4,6 +4,7 @@ #include "utils.h" #include +#include #include #include @@ -151,7 +152,8 @@ void prase_dtype(char* dtype, std::vector& types, char& endian) std::string s; s += dtype[0]; char p[10]; - s += itoa(8 * atoi(dtype + 1), p, 10); + sprintf(p, "%d", 8 * atoi(dtype + 1)); + s += p; types.push_back(s); } @@ -284,7 +286,7 @@ void prase_numpy_file(const char * path, fclose(fp); return ; } - + char magic[6]; fread(magic, sizeof(char), 6, fp);