[libbluray-devel] Add error checks

hpi1 git at videolan.org
Sun Aug 7 13:33:27 CEST 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Aug  7 13:49:48 2016 +0300| [7c107260e3f55cd3884500e3d8b5f339ff70f751] | committer: hpi1

Add error checks

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

 src/libbluray/bdj/native/java_awt_BDFontMetrics.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/bdj/native/java_awt_BDFontMetrics.c b/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
index 9b2940e..f0cd090 100644
--- a/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
+++ b/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
@@ -117,8 +117,12 @@ static int CALLBACK EnumFontCallbackW(const ENUMLOGFONTEXW *lpelfe, const NEWTEX
             size_t len = WideCharToMultiByte(CP_UTF8, 0, wdata, -1, NULL, 0, NULL, NULL);
             if (len != 0) {
                 data->filename = (char *)malloc(len);
-                WideCharToMultiByte(CP_UTF8, 0, wdata, -1, data->filename, len, NULL, NULL);
-                break;
+                if (data->filename) {
+                    if (!WideCharToMultiByte(CP_UTF8, 0, wdata, -1, data->filename, len, NULL, NULL)) {
+                        data->filename[0] = 0;
+                    }
+                    break;
+                }
             }
         }
     }



More information about the libbluray-devel mailing list