summaryrefslogtreecommitdiff
path: root/dvbsubtitle.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2013-09-07 10:39:46 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2013-09-07 10:39:46 +0200
commit3c72be23f0199bccb1a65c0bdf803cca8c47405f (patch)
tree044554c0d14e2b09eea3fd642d1a4b30f2ca91f0 /dvbsubtitle.c
parent699454ad7f3589516bfcf2dc4aefaa68787ed5be (diff)
downloadvdr-3c72be23f0199bccb1a65c0bdf803cca8c47405f.tar.gz
vdr-3c72be23f0199bccb1a65c0bdf803cca8c47405f.tar.bz2
Added checks for debug file i/o
Diffstat (limited to 'dvbsubtitle.c')
-rw-r--r--dvbsubtitle.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/dvbsubtitle.c b/dvbsubtitle.c
index 9e7d8845..f07267f1 100644
--- a/dvbsubtitle.c
+++ b/dvbsubtitle.c
@@ -7,7 +7,7 @@
* Original author: Marco Schluessler <marco@lordzodiac.de>
* With some input from the "subtitles plugin" by Pekka Virtanen <pekka.virtanen@sci.fi>
*
- * $Id: dvbsubtitle.c 3.3 2013/09/06 12:16:16 kls Exp $
+ * $Id: dvbsubtitle.c 3.4 2013/09/07 10:39:46 kls Exp $
*/
#include "dvbsubtitle.h"
@@ -106,9 +106,11 @@ cString cSubtitleDebug::WriteJpeg(const cBitmap *Bitmap, int MaxX, int MaxY)
uchar *Jpeg = RgbToJpeg(mem, w, h, Size);
cString ImgName = cString::sprintf("dbg-%03d.jpg", imgCnt++);
int f = open(ImgName, O_WRONLY | O_CREAT, DEFFILEMODE);
- if (write(f, Jpeg, Size) < 0)
- LOG_ERROR_STR(*ImgName);
- close(f);
+ if (f >= 0) {
+ if (write(f, Jpeg, Size) < 0)
+ LOG_ERROR_STR(*ImgName);
+ close(f);
+ }
free(Jpeg);
return ImgName;
}
@@ -118,13 +120,14 @@ void cSubtitleDebug::WriteHtml(const char *Format, ...)
if (!Active())
return;
cMutexLock MutexLock(&mutex);
- FILE *f = fopen("dbg-log.htm", newFile ? "w" : "a");
- va_list ap;
- va_start(ap, Format);
- vfprintf(f, Format, ap);
- va_end(ap);
- fclose(f);
- newFile = false;
+ if (FILE *f = fopen("dbg-log.htm", newFile ? "w" : "a")) {
+ va_list ap;
+ va_start(ap, Format);
+ vfprintf(f, Format, ap);
+ va_end(ap);
+ fclose(f);
+ newFile = false;
+ }
}
static cSubtitleDebug SD;