On 6/02/2013 8:18 PM, Alan Bateman wrote:
On 05/02/2013 23:49, John Zavgren wrote:
Greetings:

I modified the code in
src/windows/native/java/io/WinNTFileSystem_md.c
so that it checks the return value of realloc() and frees memory when
there is an error.

The webrev image of this change is visible at:
http://cr.openjdk.java.net/~jzavgren/8007609/webrev.01/

Thanks!
John Zavgren
Formatting aside, it looks like the change means that a realloc fail
will leave the file open. I think this is all that is needed:

WCHAR* newResult = (WCHAR*)realloc(...);
if (newResult != NULL) {
len = (*GetFinalPathNameByHandle_func)( h, newResult, len, 0);
} else {
free(result);
len = 0;
}
result = newResult;

If you move the "result = newResult" inside the if then you don't even need to free in the else.

But yes I missed the fact that the close logic at the end of the function has to be executed - so no early returns on error. Sorry about that.

David

-Alan.

Reply via email to