Skip to content

Commit 27b179a

Browse files
author
Alexander Matveev
committed
8313900: Possible NULL pointer access in NativeAudioSpectrum and NativeVideoBuffer
Backport-of: 9f180e2
1 parent bb6cbae commit 27b179a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

modules/javafx.media/src/main/native/jfxmedia/jni/NativeAudioSpectrum.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -55,6 +55,10 @@ Java_com_sun_media_jfxmediaimpl_NativeAudioSpectrum_nativeSetBands(JNIEnv *env,
5555
{
5656
CAudioSpectrum *pSpectrum = (CAudioSpectrum*)jlong_to_ptr(nativeRef);
5757
CJavaBandsHolder *pHolder = new (std::nothrow) CJavaBandsHolder();
58+
if (pHolder == NULL) {
59+
return;
60+
}
61+
5862
if (!pHolder->Init(env, bands, magnitudes, phases)) {
5963
delete pHolder;
6064
pHolder = NULL;

modules/javafx.media/src/main/native/jfxmedia/jni/NativeVideoBuffer.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,14 @@ JNIEXPORT jintArray JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_na
206206
}
207207

208208
jintArray strides = env->NewIntArray(count);
209-
jint *strideArray = new jint[count];
209+
if (strides == NULL) {
210+
return NULL;
211+
}
212+
213+
jint *strideArray = new (std::nothrow) jint[count];
214+
if (strideArray == NULL) {
215+
return NULL;
216+
}
210217

211218
for (int ii=0; ii < count; ii++) {
212219
strideArray[ii] = frame->GetStrideForPlane(ii);

0 commit comments

Comments
 (0)