Skip to content

Commit 1b65969

Browse files
committed
check memory allocations for failure in tethering view
1 parent 3351d48 commit 1b65969

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/views/tethering.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,13 @@ static int _tethering_write_image(dt_imageio_module_data_t *data,
211211
{
212212
_tethering_format_t *d = (_tethering_format_t *)data;
213213
d->buf = (float *)malloc(sizeof(float) * 4 * d->head.width * d->head.height);
214-
memcpy(d->buf, in, sizeof(float) * 4 * d->head.width * d->head.height);
215-
return 0;
214+
if(d->buf)
215+
{
216+
memcpy(d->buf, in, sizeof(float) * 4 * d->head.width * d->head.height);
217+
return 0;
218+
}
219+
else
220+
return 1;
216221
}
217222

218223
#define MARGIN DT_PIXEL_APPLY_DPI(20)
@@ -589,11 +594,14 @@ void enter(dt_view_t *self)
589594

590595
// register listener
591596
lib->listener = g_malloc0(sizeof(dt_camctl_listener_t));
592-
lib->listener->data = lib;
593-
lib->listener->image_downloaded = _camera_capture_image_downloaded;
594-
lib->listener->request_image_path = _camera_request_image_path;
595-
lib->listener->request_image_filename = _camera_request_image_filename;
596-
dt_camctl_register_listener(darktable.camctl, lib->listener);
597+
if(lib->listener)
598+
{
599+
lib->listener->data = lib;
600+
lib->listener->image_downloaded = _camera_capture_image_downloaded;
601+
lib->listener->request_image_path = _camera_request_image_path;
602+
lib->listener->request_image_filename = _camera_request_image_filename;
603+
dt_camctl_register_listener(darktable.camctl, lib->listener);
604+
}
597605
}
598606

599607
void leave(dt_view_t *self)

0 commit comments

Comments
 (0)