libragephoto: always keep old data when setJpeg malloc fails
This commit is contained in:
parent
4518ae5aa3
commit
f48bd286fe
2 changed files with 8 additions and 6 deletions
|
|
@ -1204,12 +1204,13 @@ bool RagePhoto::setJpeg(const char *data, uint32_t size, uint32_t bufferSize)
|
|||
m_data->jpegSize = size;
|
||||
}
|
||||
else if (m_data->jpegSize < size) {
|
||||
free(m_data->jpeg);
|
||||
m_data->jpeg = static_cast<char*>(malloc(size));
|
||||
if (!m_data->jpeg) {
|
||||
char *t_photoData = static_cast<char*>(malloc(size));
|
||||
if (!t_photoData) {
|
||||
m_data->error = Error::PhotoMallocError; // 16
|
||||
return false;
|
||||
}
|
||||
free(m_data->jpeg);
|
||||
m_data->jpeg = t_photoData;
|
||||
memcpy(m_data->jpeg, data, size);
|
||||
m_data->jpegSize = size;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue