camerad: fix memory leak in create_thumbnail (#2743)

* fix memory leak in create_thumbnail

* free memory returned from jpeg_mem_dest

* OMG
old-commit-hash: f0d240a7e3d1a91a3d0bac1cc9050c531105d87d
This commit is contained in:
Dean Lee
2020-12-11 20:02:16 +08:00
committed by GitHub
parent 3f999c44a9
commit fc07703c8f
+3 -1
View File
@@ -296,8 +296,9 @@ void create_thumbnail(MultiCameraState *s, CameraState *c, uint8_t *bgr_ptr) {
row_pointer[0] = row;
jpeg_write_scanlines(&cinfo, row_pointer, 1);
}
free(row);
jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo);
free(row);
MessageBuilder msg;
auto thumbnaild = msg.initEvent().initThumbnail();
@@ -308,6 +309,7 @@ void create_thumbnail(MultiCameraState *s, CameraState *c, uint8_t *bgr_ptr) {
if (s->pm != NULL) {
s->pm->send("thumbnail", msg);
}
free(thumbnail_buffer);
}
void set_exposure_target(CameraState *c, const uint8_t *pix_ptr, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip) {