RFR: 6478546: FileInputStream.read() throws OutOfMemoryError when there is plenty available [v2]

Brian Burkhalter bpb at openjdk.org
Thu Jul 27 17:02:57 UTC 2023


On Thu, 27 Jul 2023 16:35:05 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:

>> I don't see how this is possible. The value of `buf` is either `stackBuf` or a value returned by `malloc()`. In any case, this code will be superseded.
>
> Then I guess we don't need this `if`-clause

Then I think one gets an error if `0 < len < BUF_SIZE`:


$ cat free.c
#include <stdlib.h>

int main(int argc, char** argv)
{
    char stackBuf[8];
    char* buf;

    buf = stackBuf;
    free(buf);
}
bpb:test{175}$ ./free
free(14365,0x10e6a1600) malloc: *** error for object 0x7ff7b7d38280: pointer being freed was not allocated
free(14365,0x10e6a1600) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6

This is on macOS.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14981#discussion_r1276573889


More information about the security-dev mailing list