RFR: 8311647: Memory leak in Java_jdk_internal_org_jline_terminal_impl_jna_linux_CLibraryImpl_ttyname_1r
Jenny Shivayogi
duke at openjdk.org
Thu Jul 13 16:43:14 UTC 2023
On Thu, 13 Jul 2023 08:40:33 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> Allocated data on error path is deleted before return
>
> 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`.
oh! got it
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14832#discussion_r1262811609
More information about the kulla-dev
mailing list