Details
-
Bug
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
master
-
None
-
Coverity scan
-
Not applicable
Description
New defect(s) Reported-by: Coverity Scan
Showing 10 of 10 defect(s)
________________________________________________________________________________________________________
CID 1492936: Control flow issues (UNREACHABLE)
/home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 915 in couchbaseembed::CouchbaseEmbedFunctionContext::nextResultRowTree()()
909 m_oCBConnection = nullptr; 910 911 } 912 913 IPropertyTree * CouchbaseEmbedFunctionContext::nextResultRowTree() 914 { >>> CID 1492936: Control flow issues (UNREACHABLE) >>> Since the loop increment "++<anonymous>;" is unreachable, the loop body will never execute more than once. 915 for (auto cbrow : *m_pQuery) 916 { 917 auto json = cbrow.json().to_string(); 918 Owned<IPropertyTree> contentTree = createPTreeFromJSONString(json.c_str()); 919 return contentTree.getLink(); 920
________________________________________________________________________________________________________
CID 1492913: Control flow issues (UNREACHABLE)
/home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 929 in couchbaseembed::CouchbaseEmbedFunctionContext::nextResultRowIterator()()
923 924 return nullptr; 925 } 926 927 IPropertyTreeIterator * CouchbaseEmbedFunctionContext::nextResultRowIterator() 928 { >>> CID 1492913: Control flow issues (UNREACHABLE) >>> Since the loop increment "++<anonymous>;" is unreachable, the loop body will never execute more than once. 929 for (auto cbrow : *m_pQuery) 930 { 931 auto json = cbrow.json().to_string(); 932 Owned<IPropertyTree> contentTree = createPTreeFromJSONString(json.c_str()); 933 if (contentTree) 934 return contentTree->getElements("./*");
________________________________________________________________________________________________________
CID 1492890: Memory - corruptions (OVERRUN)
/home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 980 in couchbaseembed::CouchbaseEmbedFunctionContext::getDataResult(unsigned int &, void *&)()
974 975 void CouchbaseEmbedFunctionContext::getDataResult(size32_t &len, void * &result) 976 { 977 auto value = nextResultScalar(); 978 if (value && *value) 979 { >>> CID 1492890: Memory - corruptions (OVERRUN) >>> Allocating insufficient memory for the terminating null of the string. 980 rtlStrToDataX(len, result, strlen(value), value); // This feels like it may not work to me - will preallocate rather larger than we want 981 } 982 else 983 { 984 rtlStrToDataX(len, result, NULLFIELD.resultChars, NULLFIELD.stringResult); 985 }
________________________________________________________________________________________________________
CID 1492861: Memory - corruptions (OVERRUN)
/home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 1310 in couchbaseembed::CouchbaseRowBuilder::getDataResult(const RtlFieldInfo *, unsigned int &, void *&)()
1304 if (!value || !*value) 1305 { 1306 NullFieldProcessor p(field); 1307 rtlStrToDataX(len, result, p.resultChars, p.stringResult); 1308 return; 1309 } >>> CID 1492861: Memory - corruptions (OVERRUN) >>> Allocating insufficient memory for the terminating null of the string. 1310 rtlStrToDataX(len, result, strlen(value), value); // This feels like it may not work to me - will preallocate rather larger than we want 1311 } 1312 1313 double CouchbaseRowBuilder::getRealResult(const RtlFieldInfo *field) 1314 { 1315 const char * value = nextField(field);
________________________________________________________________________________________________________
CID 1402598: Uninitialized members (UNINIT_CTOR)
/home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/libcouchbase-cxx/include/libcouchbase/couchbase++/views.inl.h: 84 in Couchbase::ViewRow::ViewRow(Couchbase::Client &, const lcb_RESPVIEW_st *)()
78 79 if (resp->docresp){ 80 m_hasdoc = true; 81 m_document.handle_response(c, LCB_CALLBACK_GET, 82 reinterpret_cast<const lcb_RESPBASE*>(resp->docresp)); 83 } >>> CID 1402598: Uninitialized members (UNINIT_CTOR) >>> Non-static class member "m_hasdoc" is not initialized in this constructor nor in any functions that it calls. 84 } 85 86 void 87 ViewRow::detatch() 88 if (m_buf != NULL){ 89 return;
________________________________________________________________________________________________________
CID 1402553: Null pointer dereferences (REVERSE_INULL) /home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 1407 in couchbaseembed::CouchbaseRowBuilder::getDecimalResult(const RtlFieldInfo *, Decimal &)()
1401 return; 1402 } 1403 1404 size32_t chars; 1405 rtlDataAttr result; 1406 value.setString(strlen(dvalue), dvalue); >>> CID 1402553: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "field" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1407 if (field) 1408 { 1409 RtlDecimalTypeInfo *dtype = (RtlDecimalTypeInfo *) field->type; 1410 value.setPrecision(dtype->getDecimalDigits(), dtype->getDecimalPrecision()); 1411 } 1412 }
________________________________________________________________________________________________________
CID 1402552: Resource leaks (RESOURCE_LEAK)
/home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 1201 in couchbaseembed::CouchbaseEmbedFunctionContext::bindStringParam(const char *, unsigned int, const char *)()
1195 size32_t utf8chars; 1196 char *utf8; 1197 rtlStrToUtf8X(utf8chars, utf8, len, val); 1198 auto status = m_pQcmd->named_param(cbPlaceholder.str(), utf8); 1199 if (!status.success()) 1200 failx("Could not bind Param: %s val: %s", cbPlaceholder.str(), utf8); >>> CID 1402552: Resource leaks (RESOURCE_LEAK) >>> Variable "utf8" going out of scope leaks the storage it points to. 1201 } 1202 1203 void CouchbaseEmbedFunctionContext::bindVStringParam(const char *name, const char *val) 1204 { 1205 checkNextParam(name); 1206 bindStringParam(name, strlen(val), val);
________________________________________________________________________________________________________
CID 1402549: Resource leaks (RESOURCE_LEAK) /home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 184 in couchbaseembed::bindStringParam(unsigned int, const char *, const RtlFieldInfo *, Couchbase::QueryCommand *)()
178 size32_t utf8chars; 179 char *utf8; 180 rtlStrToUtf8X(utf8chars, utf8, len, value); 181 auto status = pQcmd->named_param(cbPlaceholder.str(), utf8); 182 if (!status.success()) 183 failx("Could not bind Param: %s val: %s", cbPlaceholder.str(), utf8); >>> CID 1402549: Resource leaks (RESOURCE_LEAK) >>> Variable "utf8" going out of scope leaks the storage it points to. 184 } 185 else 186 failx("Internal error: detected invalid CouchbaseQueryCommand while attempting to bind to field: %s", cbPlaceholder.str()); 187 } 188 189 void bindBoolParam(bool value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
________________________________________________________________________________________________________
CID 1402548: Resource leaks (RESOURCE_LEAK)
/home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 218 in couchbaseembed::bindDataParam(unsigned int, const void *, const RtlFieldInfo *, Couchbase::QueryCommand *)()
212 void *data; 213 rtlStrToDataX(bytes, data, len, value); 214 215 auto status = pQcmd->named_param(cbPlaceholder.str(), (char *)data); 216 if (!status.success()) 217 failx("Could not bind Param: %s val: %s", cbPlaceholder.str(), (char *)data); >>> CID 1402548: Resource leaks (RESOURCE_LEAK) >>> Variable "data" going out of scope leaks the storage it points to. 218 } 219 else 220 failx("Internal error: detected invalid CouchbaseQueryCommand while attempting to bind to field: %s", cbPlaceholder.str()); 221 } 222 223 void bindIntParam(__int64 value, const RtlFieldInfo * field, Couchbase::QueryCommand * pQcmd)
________________________________________________________________________________________________________
CID 1402547: Resource leaks (RESOURCE_LEAK)
/home/vamosax/build/CE/platform/HPCC-Platform/plugins/couchbase/couchbaseembed.cpp: 1129 in couchbaseembed::CouchbaseEmbedFunctionContext::bindDataParam(const char *, unsigned int, const void *)()
1123 size32_t bytes; 1124 void *data; 1125 rtlStrToDataX(bytes, data, len, val); 1126 auto status = m_pQcmd->named_param(cbPlaceholder.str(), (char *)data); 1127 if (!status.success()) 1128 failx("Could not bind Param: %s val: %s", cbPlaceholder.str(), (char *)data); >>> CID 1402547: Resource leaks (RESOURCE_LEAK) >>> Variable "data" going out of scope leaks the storage it points to. 1129 } 1130 1131 void CouchbaseEmbedFunctionContext::bindFloatParam(const char *name, float val) 1132 { 1133 checkNextParam(name); 1134 StringBuffer serialized;
________________________________________________________________________________________________________