Ticket #7170: programs_mythtranscode-negative-returns

File programs_mythtranscode-negative-returns, 2.1 KB (added by Erik Hovland <erik@…>, 11 years ago)

Check possible negative return values before feeding to functions that can't handle negative values

Line 
1Do not use a value from a function that can return negative
2
3From: Erik Hovland <erik@hovland.org>
4
5w/out checking first.
6---
7
8 mythtv/programs/mythtranscode/mpeg2fix.cpp |   10 +++++-----
9 1 files changed, 5 insertions(+), 5 deletions(-)
10
11
12diff --git a/mythtv/programs/mythtranscode/mpeg2fix.cpp b/mythtv/programs/mythtranscode/mpeg2fix.cpp
13index 038deb5..7058bd7 100644
14--- a/mythtv/programs/mythtranscode/mpeg2fix.cpp
15+++ b/mythtv/programs/mythtranscode/mpeg2fix.cpp
16@@ -1064,7 +1064,7 @@ void MPEG2fixup::WriteYUV(const char *filename, const mpeg2_info_t *info)
17     if (ret < 0)
18     {
19         VERBOSE(MPF_IMPORTANT, QString("write failed %1. %2").arg(filename)
20-                .arg(strerror(ret)));
21+                .arg(strerror(errno)));
22         goto closefd;
23     }
24     ret = write(fh, info->display_fbuf->buf[1],
25@@ -1072,7 +1072,7 @@ void MPEG2fixup::WriteYUV(const char *filename, const mpeg2_info_t *info)
26     if (ret < 0)
27     {
28         VERBOSE(MPF_IMPORTANT, QString("write failed %1. %2").arg(filename)
29-                .arg(strerror(ret)));
30+                .arg(strerror(errno)));
31         goto closefd;
32     }
33     ret = write(fh, info->display_fbuf->buf[2],
34@@ -1080,7 +1080,7 @@ void MPEG2fixup::WriteYUV(const char *filename, const mpeg2_info_t *info)
35     if (ret < 0)
36     {
37         VERBOSE(MPF_IMPORTANT, QString("write failed %1. %2").arg(filename)
38-                .arg(strerror(ret)));
39+                .arg(strerror(errno)));
40         goto closefd;
41     }
42 closefd:
43@@ -1098,7 +1098,7 @@ void MPEG2fixup::WriteData(const char *filename, uint8_t *data, int size)
44     int ret = write(fh, data, size);
45     if (ret < 0)
46         VERBOSE(MPF_IMPORTANT, QString("write failed %1. %2").arg(filename)
47-                .arg(strerror(ret)));
48+                .arg(strerror(errno)));
49     close(fh);
50 }
51 
52@@ -1213,7 +1213,7 @@ int MPEG2fixup::BuildFrame(AVPacket *pkt, QString fname)
53     }
54 
55     pkt->size = avcodec_encode_video(c, pkt->data, outbuf_size, picture);
56-    if (!fname.isEmpty())
57+    if (!fname.isEmpty() && pkt->size >= 0)
58     {
59         QString ename = fname + ".enc";
60         QByteArray aename = ename.toLocal8Bit();