libragephoto: fix memory issues with Jpeg saving
- RagePhoto.c: return PHOTOREADERROR when no Jpeg is being set when ragephotodata_savef is being called with Jpeg format - RagePhoto.cpp: return PhotoReadError when no Jpeg is being set when RagePhoto::save is being called with Jpeg format
This commit is contained in:
parent
b150959727
commit
b87fd1d8fd
2 changed files with 16 additions and 8 deletions
|
|
@ -972,10 +972,14 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (photoFormat == RAGEPHOTO_FORMAT_JPEG) {
|
else if (photoFormat == RAGEPHOTO_FORMAT_JPEG) {
|
||||||
const size_t length = ragephotodata_getsavesizef(rp_data, NULL, photoFormat);
|
if (rp_data->jpeg) {
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
writeBuffer(rp_data->jpeg, data, &pos, rp_data->jpegSize, rp_data->jpegSize);
|
||||||
writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize);
|
}
|
||||||
|
else {
|
||||||
|
rp_data->error = RAGEPHOTO_ERROR_PHOTOREADERROR; // 17
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
rp_data->error = RAGEPHOTO_ERROR_NOERROR; // 255
|
rp_data->error = RAGEPHOTO_ERROR_NOERROR; // 255
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -943,10 +943,14 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (photoFormat == PhotoFormat::JPEG) {
|
else if (photoFormat == PhotoFormat::JPEG) {
|
||||||
const size_t length = saveSize(photoFormat, rp_data, nullptr);
|
if (rp_data->jpeg) {
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
writeBuffer(rp_data->jpeg, data, &pos, rp_data->jpegSize, rp_data->jpegSize);
|
||||||
writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize);
|
}
|
||||||
|
else {
|
||||||
|
rp_data->error = Error::PhotoReadError; // 17
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
rp_data->error = Error::NoError; // 255
|
rp_data->error = Error::NoError; // 255
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue