diff options
author | Uri Lublin <uril@redhat.com> | 2016-10-16 14:44:52 +0300 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2016-10-17 10:49:41 +0100 |
commit | 44624ed8bf774eb2c6b0fa1c097e87b3b9eef397 (patch) | |
tree | ca33e8a1f2781f0967da8184e20706c8ce53c166 | |
parent | 09b12a55d07f6901eea20362c975079860490683 (diff) |
mjpeg_encoder_new: allocate memory after sanity check
This patch prevents a leak in case the function returns early
Found by coverity.
Signed-off-by: Uri Lublin <uril@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r-- | server/mjpeg-encoder.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c index 1649516a..d95c645e 100644 --- a/server/mjpeg-encoder.c +++ b/server/mjpeg-encoder.c @@ -1372,10 +1372,11 @@ VideoEncoder *mjpeg_encoder_new(SpiceVideoCodecType codec_type, bitmap_ref_t bitmap_ref, bitmap_unref_t bitmap_unref) { - MJpegEncoder *encoder = spice_new0(MJpegEncoder, 1); + MJpegEncoder *encoder; spice_return_val_if_fail(codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG, NULL); + encoder = spice_new0(MJpegEncoder, 1); encoder->base.destroy = mjpeg_encoder_destroy; encoder->base.encode_frame = mjpeg_encoder_encode_frame; encoder->base.client_stream_report = mjpeg_encoder_client_stream_report; |