RFR: 8311647: Memory leak in Java_jdk_internal_org_jline_terminal_impl_jna_linux_CLibraryImpl_ttyname_1r
Aleksey Shipilev
shade at openjdk.org
Thu Jul 13 08:44:08 UTC 2023
On Tue, 11 Jul 2023 16:51:15 GMT, Jenny Shivayogi <duke at openjdk.org> wrote:
> Allocated data on error path is deleted before return
Changes requested by shade (Reviewer).
src/jdk.internal.le/linux/native/lible/CLibrary.cpp line 191:
> 189: if (error != 0) {
> 190: throw_errno(env);
> 191: delete[] data;
While JNI would not transfer control immediately on `Throw`, and would only throw it on return, it is a good style to do cleanups first, and then do throw, followed by immediate return.
In other words, flip the order of `delete[]` and `throw_errno`.
-------------
PR Review: https://git.openjdk.org/jdk/pull/14832#pullrequestreview-1527918713
PR Review Comment: https://git.openjdk.org/jdk/pull/14832#discussion_r1262223066
More information about the kulla-dev
mailing list