In FTS3, avoid calling memcpy() with a NULL source pointer, even if the

transfer amount is zero bytes.

FossilOrigin-Name: 1abb83d29a06308c96bea379311b390240347c5f81824749348d18ad75840c96
This commit is contained in:
drh
2018-12-21 18:51:27 +00:00
parent 8bcc686614
commit afdc9e23fc
4 changed files with 127 additions and 8 deletions
+6 -1
View File
@@ -1608,6 +1608,11 @@ int sqlite3Fts3SegReaderNew(
Fts3SegReader *pReader; /* Newly allocated SegReader object */
int nExtra = 0; /* Bytes to allocate segment root node */
assert( zRoot!=0 || nRoot==0 );
#ifdef CORRUPT_DB
assert( zRoot!=0 || CORRUPT_DB );
#endif
if( iStartLeaf==0 ){
nExtra = nRoot + FTS3_NODE_PADDING;
}
@@ -1628,7 +1633,7 @@ int sqlite3Fts3SegReaderNew(
pReader->aNode = (char *)&pReader[1];
pReader->rootOnly = 1;
pReader->nNode = nRoot;
memcpy(pReader->aNode, zRoot, nRoot);
if( nRoot ) memcpy(pReader->aNode, zRoot, nRoot);
memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);
}else{
pReader->iCurrentBlock = iStartLeaf-1;