On Thu, 2 Dec 2021 22:05:00 GMT, Alexander Zuev <[email protected]> wrote:
>> Made colorBits and maskBits arrays dynamic so they are allocated on heap
>> instead of stack.
>> Added regression test.
>
> Alexander Zuev has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Eliminate potential resource leak.
Changes requested by aivanov (Reviewer).
src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp line 1068:
> 1066: }
> 1067:
> 1068: if (colorBits != NULL) {
I think this way defeats the use of exception to handle allocation error. You
could use:
```c++
long *colorBits = (long*)malloc(MAX_ICON_SIZE * MAX_ICON_SIZE * sizeof(long));
if (colorBits != NULL) {
to achieve the same effect, which is shorter and clearer.
src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp line 1102:
> 1100: }
> 1101: // Release DC
> 1102: ReleaseDC(NULL, dc);
The DC has to be released even if `colorBits` allocation failed, so this needs
to be after `if (colorBits != NULL)`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6473