From 3c88edd00704e1440fb005a9799f428d76adbbdc Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 3 Sep 2016 14:51:28 +0200 Subject: [PATCH] fix Coverity issues --- src/App/Expression.h | 2 +- src/Base/FileInfo.cpp | 24 ++++++++++++------------ src/Base/PyTools.c | 4 +++- src/Base/gzstream.h | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/App/Expression.h b/src/App/Expression.h index 229498842..8c9a1df3d 100644 --- a/src/App/Expression.h +++ b/src/App/Expression.h @@ -507,7 +507,7 @@ public: std::string string; FunctionExpression::Function func; ObjectIdentifier::String string_or_identifier; - semantic_type() {} + semantic_type() : expr(0), ivalue(0), fvalue(0), func(FunctionExpression::NONE) {} }; #define YYSTYPE semantic_type diff --git a/src/Base/FileInfo.cpp b/src/Base/FileInfo.cpp index afff7dd17..96e027392 100644 --- a/src/Base/FileInfo.cpp +++ b/src/Base/FileInfo.cpp @@ -169,31 +169,31 @@ std::string FileInfo::getTempFileName(const char* FileName, const char* Path) return std::string(ConvertFromWideString(std::wstring(buf))); #else - char buf[PATH_MAX+1]; + std::string buf; // Path where the file is located if (Path) - std::strncpy(buf, Path, PATH_MAX); + buf = Path; else - std::strncpy(buf, getTempPath().c_str(), PATH_MAX); - - buf[PATH_MAX] = 0; // null termination needed + buf = getTempPath(); // File name in the path if (FileName) { - std::strcat(buf, "/"); - std::strcat(buf, FileName); - std::strcat(buf, "XXXXXX"); + buf += "/"; + buf += FileName; + buf += "XXXXXX"; + } + else { + buf += "/fileXXXXXX"; } - else - std::strcat(buf, "/fileXXXXXX"); - int id = mkstemp(buf); + int id = mkstemp(static_cast(buf.c_str()); if (id > -1) { FILE* file = fdopen(id, "w"); fclose(file); + unlink(buf.c_str()); } - return std::string(buf); + return buf; #endif } diff --git a/src/Base/PyTools.c b/src/Base/PyTools.c index a58400396..c08d3b886 100644 --- a/src/Base/PyTools.c +++ b/src/Base/PyTools.c @@ -40,8 +40,10 @@ PP_Run_Method(PyObject *pobject, const char *method, Py_Initialize(); /* init if first time */ pmeth = PyObject_GetAttrString(pobject, method); - if (pmeth == NULL) /* get callable object */ + if (pmeth == NULL) { /* get callable object */ + va_end(argslist); return -1; /* bound method? has self */ + } /* handle zero args different */ // if(resfmt == 0 || strcmp(resfmt,"") == 0) // pargs = Py_BuildValue("()"); diff --git a/src/Base/gzstream.h b/src/Base/gzstream.h index 5dd7cb57a..02472200a 100644 --- a/src/Base/gzstream.h +++ b/src/Base/gzstream.h @@ -65,7 +65,7 @@ private: int flush_buffer(); public: - gzstreambuf() : opened(0) { + gzstreambuf() : file(0), opened(0), mode(0) { setp( buffer, buffer + (bufferSize-1)); setg( buffer + 4, // beginning of putback area buffer + 4, // read position