diff options
author | Aleksoid <aleksoid@users.sourceforge.net> | 2011-08-04 04:22:11 +0400 |
---|---|---|
committer | Aleksoid <aleksoid@users.sourceforge.net> | 2011-08-04 04:22:11 +0400 |
commit | bd96d9168129cbab728094c5b5773486fb291635 (patch) | |
tree | f509c300aea440c9fb9e3ad1d2c4c1dac2ab6ab2 /src/Subtitles | |
parent | d068f7bd12aed3a1d9ad64806113119a87c883ef (diff) |
Fix : fix Subtitle render to prevent memory leak & crash, ticket #1563.
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3560 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/Subtitles')
-rw-r--r-- | src/Subtitles/RTS.cpp | 10 | ||||
-rw-r--r-- | src/Subtitles/Rasterizer.cpp | 8 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp index e06f9ff11..918a0e93d 100644 --- a/src/Subtitles/RTS.cpp +++ b/src/Subtitles/RTS.cpp @@ -118,6 +118,10 @@ void CWord::Paint(CPoint p, CPoint org) return;
}
+ if(!m_str.Find(L"m 0 0 l")) { //some unknow thing from Apple Text Media Handler
+ return;
+ }
+
if(!m_fDrawn) {
if(!CreatePath()) {
return;
@@ -125,8 +129,10 @@ void CWord::Paint(CPoint p, CPoint org) Transform(CPoint((org.x-p.x)*8, (org.y-p.y)*8));
- if(!ScanConvert()) {
- return;
+ __try{
+ if(!ScanConvert()) return;
+ }__except (EXCEPTION_EXECUTE_HANDLER) {
+ return;
}
if(m_style.borderStyle == 0 && (m_style.outlineWidthX+m_style.outlineWidthY > 0)) {
diff --git a/src/Subtitles/Rasterizer.cpp b/src/Subtitles/Rasterizer.cpp index 06cec1cc2..712c5cbd7 100644 --- a/src/Subtitles/Rasterizer.cpp +++ b/src/Subtitles/Rasterizer.cpp @@ -757,7 +757,15 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) // fixed image height
mOverlayHeight=((height+14)>>3) + 1;
+ if(mOverlayWidth > 3300 || mOverlayHeight > 3300) { //avoid overflow
+ return false;
+ }
+
mpOverlayBuffer = (byte*)_aligned_malloc(2 * mOverlayWidth * mOverlayHeight, 16);
+ if(!mpOverlayBuffer) {
+ return false;
+ }
+
memset(mpOverlayBuffer, 0, 2 * mOverlayWidth * mOverlayHeight);
// Are we doing a border?
|