Commit 3667c4db authored by unknown's avatar unknown

BUG #21036, myOperation->getBlobHandle(..) on non-existing column cause segmentation fault

add judgement to avoid NULL pointer's operation(segmentaion fault)


ndb/src/ndbapi/NdbOperation.cpp:
  if getColumn return NULL, set error code and return NULL in getBlobHandle
ndb/src/ndbapi/ndberror.c:
  change the err message more appropriate
parent 89ba8448
...@@ -319,13 +319,31 @@ NdbOperation::setValue( Uint32 anAttrId, ...@@ -319,13 +319,31 @@ NdbOperation::setValue( Uint32 anAttrId,
NdbBlob* NdbBlob*
NdbOperation::getBlobHandle(const char* anAttrName) NdbOperation::getBlobHandle(const char* anAttrName)
{ {
return getBlobHandle(theNdbCon, m_currentTable->getColumn(anAttrName)); const NdbColumnImpl* col = m_currentTable->getColumn(anAttrName);
if (col == NULL)
{
setErrorCode(4004);
return NULL;
}
else
{
return getBlobHandle(theNdbCon, col);
}
} }
NdbBlob* NdbBlob*
NdbOperation::getBlobHandle(Uint32 anAttrId) NdbOperation::getBlobHandle(Uint32 anAttrId)
{ {
return getBlobHandle(theNdbCon, m_currentTable->getColumn(anAttrId)); const NdbColumnImpl* col = m_currentTable->getColumn(anAttrId);
if (col == NULL)
{
setErrorCode(4004);
return NULL;
}
else
{
return getBlobHandle(theNdbCon, col);
}
} }
int int
......
...@@ -401,7 +401,7 @@ ErrorBundle ErrorCodes[] = { ...@@ -401,7 +401,7 @@ ErrorBundle ErrorCodes[] = {
* Still uncategorized * Still uncategorized
*/ */
{ 720, AE, "Attribute name reused in table definition" }, { 720, AE, "Attribute name reused in table definition" },
{ 4004, AE, "Attribute name not found in the Table" }, { 4004, AE, "Attribute name or id not found in the table" },
{ 4100, AE, "Status Error in NDB" }, { 4100, AE, "Status Error in NDB" },
{ 4101, AE, "No connections to NDB available and connect failed" }, { 4101, AE, "No connections to NDB available and connect failed" },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment