[mythtv] [patch] added asserts to osdtypes and nvp
Daniel Thor Kristjansson
danielk at mrl.nyu.edu
Sun Nov 14 21:04:55 UTC 2004
I found OSDSet would try to allocate negative sized arrays if passed
a frame_interval of 0. I added an assert on the array size in
osdtypes.cpp, and added an assert on frame_interval sets in
NuppelVideoPlayer.cpp so that if these errors occur it is not deep
inside the C++ library.
-- Daniel
-------------- next part --------------
Index: libs/libmythtv/osdtypes.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/osdtypes.cpp,v
retrieving revision 1.54
diff -u -r1.54 osdtypes.cpp
--- libs/libmythtv/osdtypes.cpp 15 Oct 2004 03:06:40 -0000 1.54
+++ libs/libmythtv/osdtypes.cpp 14 Nov 2004 21:01:36 -0000
@@ -1,7 +1,8 @@
#include <qimage.h>
#include <qmap.h>
#include <qregexp.h>
-#include <math.h>
+#include <cmath>
+#include <cassert>
#include <iostream>
using namespace std;
@@ -1149,6 +1150,7 @@
m_displayrect = displayrect;
m_drawwidth = displayrect.width();
+ assert(m_drawwidth>=0);
m_drawMap = new unsigned char[m_drawwidth + 1];
for (int i = 0; i < m_drawwidth; i++)
m_drawMap[i] = 0;
@@ -1208,6 +1210,7 @@
delete [] m_drawMap;
+ assert(m_drawwidth>=0);
m_drawMap = new unsigned char[m_drawwidth + 1];
for (int i = 0; i < m_drawwidth; i++)
m_drawMap[i] = 0;
Index: libs/libmythtv/NuppelVideoPlayer.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp,v
retrieving revision 1.385
diff -u -r1.385 NuppelVideoPlayer.cpp
--- libs/libmythtv/NuppelVideoPlayer.cpp 13 Nov 2004 22:29:44 -0000 1.385
+++ libs/libmythtv/NuppelVideoPlayer.cpp 14 Nov 2004 21:01:37 -0000
@@ -274,6 +274,7 @@
play_speed = audio_stretchfactor;
normal_speed = false;
frame_interval = (int)(1000000.0 / video_frame_rate / play_speed);
+ assert(frame_interval>0);
if (osd && forceVideoOutput != kVideoOutput_IVTV)
osd->SetFrameInterval(frame_interval);
if (videosync != NULL)
@@ -296,6 +297,8 @@
}
frame_interval = (int)(1000000.0 * temp_ffrew_skip /
video_frame_rate / speed);
+ assert(frame_interval>0);
+
new_ffrew_skip = temp_ffrew_skip;
//cout << "ffrew_skip=" << new_ffrew_skip
//<< ", frame_interval=" << frame_interval << endl;
@@ -456,6 +459,7 @@
videoOutput->GetDrawSize(dispx, dispy, dispw, disph);
+ assert(frame_interval>0);
osd->Reinit(video_width, video_height, frame_interval,
dispx, dispy, dispw, disph);
}
More information about the mythtv-dev
mailing list