You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
Fix a few cppcheck issues
Found the following: * Potential stack explosions with alloca() usage on potentially large strings * Memory leaks in WriteEngineServer * Stack usage out of scope in dataconvert * A typo in an 'if' statement in dataconvert
This commit is contained in:
@ -67,7 +67,7 @@ std::string Func_ucase::getStrVal(rowgroup::Row& row,
|
||||
return "";
|
||||
|
||||
size_t strwclen = utf8::idb_mbstowcs(0, tstr.c_str(), 0) + 1;
|
||||
wchar_t* wcbuf = (wchar_t*)alloca(strwclen * sizeof(wchar_t));
|
||||
wchar_t* wcbuf = new wchar_t[strwclen];
|
||||
strwclen = utf8::idb_mbstowcs(wcbuf, tstr.c_str(), strwclen);
|
||||
wstring wstr(wcbuf, strwclen);
|
||||
|
||||
@ -75,9 +75,12 @@ std::string Func_ucase::getStrVal(rowgroup::Row& row,
|
||||
wstr[i] = std::towupper(wstr[i]);
|
||||
|
||||
size_t strmblen = utf8::idb_wcstombs(0, wstr.c_str(), 0) + 1;
|
||||
char* outbuf = (char*)alloca(strmblen * sizeof(char));
|
||||
char* outbuf = new char[strmblen];
|
||||
strmblen = utf8::idb_wcstombs(outbuf, wstr.c_str(), strmblen);
|
||||
return string(outbuf, strmblen);
|
||||
std::string ret(outbuf, strmblen);
|
||||
delete [] outbuf;
|
||||
delete [] wcbuf;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user