[libbluray-devel] Added checks for null pointers
hpi1
git at videolan.org
Thu Apr 11 14:43:45 CEST 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Apr 11 09:36:56 2013 +0300| [130a9824b1dfc9a81ca560fafd56e807dd12f18c] | committer: hpi1
Added checks for null pointers
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=130a9824b1dfc9a81ca560fafd56e807dd12f18c
---
src/libbluray/bdj/native/java_awt_BDFontMetrics.c | 27 +++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/libbluray/bdj/native/java_awt_BDFontMetrics.c b/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
index 26a25d4..718cb9f 100644
--- a/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
+++ b/src/libbluray/bdj/native/java_awt_BDFontMetrics.c
@@ -63,6 +63,11 @@ Java_java_awt_BDFontMetrics_destroyN(JNIEnv * env, jclass cls, jlong ftLib)
{
#ifdef HAVE_FT2
FT_Library lib = (FT_Library)(intptr_t)ftLib;
+
+ if (!lib) {
+ return;
+ }
+
FT_Done_FreeType(lib);
#endif
}
@@ -78,6 +83,10 @@ Java_java_awt_BDFontMetrics_loadFontN(JNIEnv * env, jobject obj, jlong ftLib, js
jfieldID fid;
FT_Library lib = (FT_Library)(intptr_t)ftLib;
+ if (!lib) {
+ return 0;
+ }
+
name = (*env)->GetStringUTFChars(env, fontName, NULL);
result = FT_New_Face(lib, name, 0, &ftFace);
(*env)->ReleaseStringUTFChars(env, fontName, name);
@@ -106,6 +115,11 @@ Java_java_awt_BDFontMetrics_destroyFontN(JNIEnv *env, jobject obj, jlong ftFace)
{
#ifdef HAVE_FT2
FT_Face face = (FT_Face)(intptr_t)ftFace;
+
+ if (!face) {
+ return;
+ }
+
FT_Done_Face(face);
#endif
}
@@ -115,6 +129,11 @@ Java_java_awt_BDFontMetrics_charWidthN(JNIEnv * env, jobject obj, jlong ftFace,
{
#ifdef HAVE_FT2
FT_Face face = (FT_Face)(intptr_t)ftFace;
+
+ if (!face) {
+ return 0;
+ }
+
if (FT_Load_Char(face, c, FT_LOAD_DEFAULT))
return 0;
return face->glyph->metrics.horiAdvance >> 6;
@@ -132,6 +151,10 @@ Java_java_awt_BDFontMetrics_stringWidthN(JNIEnv * env, jobject obj, jlong ftFace
jint i, width;
FT_Face face = (FT_Face)(intptr_t)ftFace;
+ if (!face) {
+ return 0;
+ }
+
length = (*env)->GetStringLength(env, string);
if (length <= 0)
return 0;
@@ -163,6 +186,10 @@ Java_java_awt_BDFontMetrics_charsWidthN(JNIEnv * env, jobject obj, jlong ftFace,
jint i, width;
FT_Face face = (FT_Face)(intptr_t)ftFace;
+ if (!face) {
+ return 0;
+ }
+
chars = (jchar *)malloc(sizeof(jchar) * length);
if (chars == NULL)
return 0;
More information about the libbluray-devel
mailing list