From 3c4d128365b696d9c196719df07a372d018594e1 Mon Sep 17 00:00:00 2001 From: pchelko Date: Wed, 14 Aug 2013 16:17:28 +0400 Subject: [PATCH] 8013454: [parfait] Memory leak in jdk/src/windows/native/sun/windows/awt_Cursor.cpp 8012079: [parfait] possible null pointer dereference in jdk/src/windows/native/sun/windows/awt_Font.cpp Reviewed-by: art, serb --- src/windows/native/sun/windows/awt_Cursor.cpp | 13 ++++++++++--- src/windows/native/sun/windows/awt_Font.cpp | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/windows/native/sun/windows/awt_Cursor.cpp b/src/windows/native/sun/windows/awt_Cursor.cpp index 477fe80ee..790160116 100644 --- a/src/windows/native/sun/windows/awt_Cursor.cpp +++ b/src/windows/native/sun/windows/awt_Cursor.cpp @@ -391,9 +391,16 @@ Java_sun_awt_windows_WCustomCursor_createCursorIndirect( DASSERT(hCursor); - AwtCursor::setPData(self, ptr_to_jlong(new AwtCursor(env, hCursor, self, xHotSpot, - yHotSpot, nW, nH, nSS, cols, - (BYTE *)andMaskPtr))); + try { + AwtCursor::setPData(self, ptr_to_jlong(new AwtCursor(env, hCursor, self, xHotSpot, + yHotSpot, nW, nH, nSS, cols, + (BYTE *)andMaskPtr))); + } catch (...) { + if (cols) { + delete[] cols; + } + throw; + } CATCH_BAD_ALLOC; } diff --git a/src/windows/native/sun/windows/awt_Font.cpp b/src/windows/native/sun/windows/awt_Font.cpp index 185514c19..d0d31ff0d 100644 --- a/src/windows/native/sun/windows/awt_Font.cpp +++ b/src/windows/native/sun/windows/awt_Font.cpp @@ -510,6 +510,11 @@ void AwtFont::LoadMetrics(JNIEnv *env, jobject fontMetrics) jobject font = env->GetObjectField(fontMetrics, AwtFont::fontID); AwtFont* awtFont = AwtFont::GetFont(env, font); + if (!awtFont) { + /* failed to get font */ + return; + } + HDC hDC = ::GetDC(0); DASSERT(hDC != NULL); -- GitLab