RFR: 8342870: Errors related to unused code on Windows after 8339120 in accessibility [v5]
Alexey Ivanov
aivanov at openjdk.org
Fri Jan 24 20:15:54 UTC 2025
On Thu, 23 Jan 2025 05:46:29 GMT, Julian Waters <jwaters at openjdk.org> wrote:
>> src/jdk.accessibility/windows/native/jabswitch/jabswitch.cpp line 334:
>>
>>> 332: TCHAR dataBuffer[DEFAULT_ALLOC];
>>> 333: TCHAR *data = dataBuffer;
>>> 334: // bool freeData = false;
>>
>> This should be set to `true` if `data` is reallocated, otherwise both `regEnable` and `regDeleteValue` leak `data`.
>>
>> https://github.com/openjdk/jdk/blob/4a9fba615da0dfa6646ecb9fd9d929f74fe6875e/src/jdk.accessibility/windows/native/jabswitch/jabswitch.cpp#L336-L341
>>
>> In fact, the above statement should probably be removed — the following code uses only `dataBuffer` which does not contain any data if the buffer was dynamically allocated and assigned to `data`.
>
> By the above statement are you referring to the lines 336 to 341? I'll admit I'm a little lost for this one
I'll submit a new bug to address this problem.
It's not just a matter of an unused variables, it's the logic error: if the buffer is too small, *a new buffer is allocated*, yet this new buffer isn't deleted afterwards, nor is used to read the value retrieved from the registry.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21656#discussion_r1929185886
More information about the client-libs-dev
mailing list