mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Avoid passing NULL pointers to memcmp() or memcpy(), even when the
"number-of-bytes" argument is passed 0. FossilOrigin-Name: 56ff72ab44288296efc99a608f7edc4346366a50
This commit is contained in:
@ -374,9 +374,7 @@ static int sessionSerializeValue(
|
||||
|
||||
if( aBuf ){
|
||||
sessionVarintPut(&aBuf[1], n);
|
||||
memcpy(&aBuf[nVarint + 1], eType==SQLITE_TEXT ?
|
||||
sqlite3_value_text(pValue) : sqlite3_value_blob(pValue), n
|
||||
);
|
||||
if( n ) memcpy(&aBuf[nVarint + 1], z, n);
|
||||
}
|
||||
|
||||
nByte = 1 + nVarint + n;
|
||||
@ -1792,7 +1790,7 @@ static void sessionAppendBlob(
|
||||
int nBlob,
|
||||
int *pRc
|
||||
){
|
||||
if( 0==sessionBufferGrow(p, nBlob, pRc) ){
|
||||
if( nBlob>0 && 0==sessionBufferGrow(p, nBlob, pRc) ){
|
||||
memcpy(&p->aBuf[p->nBuf], aBlob, nBlob);
|
||||
p->nBuf += nBlob;
|
||||
}
|
||||
@ -1978,13 +1976,13 @@ static int sessionAppendUpdate(
|
||||
}
|
||||
|
||||
default: {
|
||||
int nByte;
|
||||
int nHdr = 1 + sessionVarintGet(&pCsr[1], &nByte);
|
||||
int n;
|
||||
int nHdr = 1 + sessionVarintGet(&pCsr[1], &n);
|
||||
assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );
|
||||
nAdvance = nHdr + nByte;
|
||||
nAdvance = nHdr + n;
|
||||
if( eType==sqlite3_column_type(pStmt, i)
|
||||
&& nByte==sqlite3_column_bytes(pStmt, i)
|
||||
&& 0==memcmp(&pCsr[nHdr], sqlite3_column_blob(pStmt, i), nByte)
|
||||
&& n==sqlite3_column_bytes(pStmt, i)
|
||||
&& (n==0 || 0==memcmp(&pCsr[nHdr], sqlite3_column_blob(pStmt, i), n))
|
||||
){
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user