Skip to content

Commit 794a440

Browse files
committed
Fix exception calling memcpy with null pointer
In the event of mnBufferLen == 0, mpBuf could be null.
1 parent a8c4be6 commit 794a440

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/CppSQLite3.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ SQLite3Memory::SQLite3Memory(SQLite3Memory const &other)
5757
throw CppSQLite3Exception(CPPSQLITE_ERROR, ALLOCATION_ERROR_MESSAGE,
5858
DONT_DELETE_MSG);
5959
}
60-
std::memcpy(mpBuf, other.mpBuf, mnBufferLen);
60+
if (mnBufferLen > 0) {
61+
std::memcpy(mpBuf, other.mpBuf, mnBufferLen);
62+
}
6163
}
6264

6365
SQLite3Memory &SQLite3Memory::operator=(SQLite3Memory const &lhs) {

0 commit comments

Comments
 (0)