Skip to content

Commit d34f7d1

Browse files
committed
fix(toxav): handle vpx_image_alloc failure
1 parent 9dcc2f5 commit d34f7d1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Diff for: toxav/toxav.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,7 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
10551055
goto RETURN;
10561056
}
10571057

1058+
// we start with I-frames (full frames) and then switch to normal mode later
10581059
if (call->video_rtp->ssrc < VIDEO_SEND_X_KEYFRAMES_FIRST) {
10591060
// Key frame flag for first frames
10601061
vpx_encode_flags = VPX_EFLAG_FORCE_KF;
@@ -1069,15 +1070,18 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
10691070
++call->video_rtp->ssrc;
10701071
}
10711072

1072-
// we start with I-frames (full frames) and then switch to normal mode later
1073-
10741073
{ /* Encode */
10751074
vpx_image_t img;
10761075
img.w = 0;
10771076
img.h = 0;
10781077
img.d_w = 0;
10791078
img.d_h = 0;
1080-
vpx_img_alloc(&img, VPX_IMG_FMT_I420, width, height, 0);
1079+
if (vpx_img_alloc(&img, VPX_IMG_FMT_I420, width, height, 0) == nullptr) {
1080+
pthread_mutex_unlock(call->mutex_video);
1081+
LOGGER_ERROR(av->log, "Could not allocate image for frame");
1082+
rc = TOXAV_ERR_SEND_FRAME_INVALID;
1083+
goto RETURN;
1084+
}
10811085

10821086
/* I420 "It comprises an NxM Y plane followed by (N/2)x(M/2) V and U planes."
10831087
* http://fourcc.org/yuv.php#IYUV

0 commit comments

Comments
 (0)