libbluray | branch: master | hpi1 <[email protected]> | Tue Apr  5 14:30:44 
2011 +0300| [f06398fe6e208d327150ae40b7a9f99a059bfb63] | committer: hpi1

Fixed segfault when log file (BD_DEBUG_FILE) can't be opened

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=f06398fe6e208d327150ae40b7a9f99a059bfb63
---

 src/util/logging.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/util/logging.c b/src/util/logging.c
index ee50acd..94473cb 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -69,8 +69,13 @@ void bd_debug(const char *file, int line, uint32_t mask, 
const char *format, ...
 
         // Send DEBUG to file?
         if ((env = getenv("BD_DEBUG_FILE"))) {
-            logfile = fopen(env, "wb");
-            setvbuf(logfile, NULL, _IOLBF, 0);
+            FILE *fp = fopen(env, "wb");
+            if (fp) {
+                logfile = fp;
+                setvbuf(logfile, NULL, _IOLBF, 0);
+            } else {
+                fprintf(logfile, "%s:%d: Error opening log file %s\n", 
__FILE__, __LINE__, env);
+            }
         }
     }
 

_______________________________________________
libbluray-devel mailing list
[email protected]
http://mailman.videolan.org/listinfo/libbluray-devel

Reply via email to