Mercurial > hg > icedtea8-forest > hotspot
changeset 10784:d64fa7b92b5b
8193234: When using -Xcheck:jni an internally allocated buffer can leak
Reviewed-by: shade, hseigel
author | dholmes |
---|---|
date | Fri, 08 Feb 2019 20:51:55 -0500 |
parents | c7ef664f8649 |
children | 34f5c1a4ba37 |
files | src/share/vm/prims/jniCheck.cpp |
diffstat | 1 files changed, 4 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/prims/jniCheck.cpp Tue Jul 18 09:53:54 2017 +0200 +++ b/src/share/vm/prims/jniCheck.cpp Fri Feb 08 20:51:55 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -428,21 +428,20 @@ size_t sz; void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz); switch (mode) { + // As we never make copies, mode 0 and JNI_COMMIT are the same. case 0: - memcpy(orig_result, carray, sz); - GuardedMemory::free_copy(carray); - break; case JNI_COMMIT: memcpy(orig_result, carray, sz); break; case JNI_ABORT: - GuardedMemory::free_copy(carray); break; default: tty->print_cr("%s: Unrecognized mode %i releasing array " PTR_FORMAT " elements " PTR_FORMAT, fn_name, mode, p2i(obj), p2i(carray)); NativeReportJNIFatalError(thr, "Unrecognized array release mode"); } + // We always need to release the copy we made with GuardedMemory + GuardedMemory::free_copy(carray); return orig_result; }