summaryrefslogtreecommitdiff
path: root/gst/pnm/gstpnmenc.c
diff options
context:
space:
mode:
authorVineeth TM <vineeth.tm@samsung.com>2015-12-17 08:51:48 +0900
committerSebastian Dröge <sebastian@centricular.com>2015-12-17 10:26:48 +0100
commit10ed707b6085e3edc14e897ba53dbd321e4f557b (patch)
tree1be2985dc62aec4e2e4070450144756d36a4ebd7 /gst/pnm/gstpnmenc.c
parent4d88848faed2e6a061f8e15103727c827c79f5d5 (diff)
downloadgstreamer-plugins-bad-10ed707b6085e3edc14e897ba53dbd321e4f557b.tar.gz
pnmenc: Fix wrong logic leading to memory mishandling
While encoding the frame in ASCII mode, per component four bytes are needed and after every 20 bytes, a \n will be added. So the calculation should be size = size * (4 + 1 / 20). This should exclude the header being written. Since header is also being included in the calculations, memory mishandlings are happening. https://bugzilla.gnome.org/show_bug.cgi?id=759520
Diffstat (limited to 'gst/pnm/gstpnmenc.c')
-rw-r--r--gst/pnm/gstpnmenc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gst/pnm/gstpnmenc.c b/gst/pnm/gstpnmenc.c
index d88627359..32fd6f68e 100644
--- a/gst/pnm/gstpnmenc.c
+++ b/gst/pnm/gstpnmenc.c
@@ -202,10 +202,10 @@ gst_pnmenc_handle_frame (GstVideoEncoder * encoder, GstVideoCodecFrame * frame)
if (pnmenc->info.encoding == GST_PNM_ENCODING_ASCII) {
/* Per component 4 bytes are used in case of ASCII encoding */
- size = size * 4;
+ size = size * 4 + size / 20;
size += strlen (header);
frame->output_buffer =
- gst_video_encoder_allocate_output_buffer (encoder, (size + size / 20));
+ gst_video_encoder_allocate_output_buffer (encoder, (size));
} else {
size += strlen (header);
frame->output_buffer =