Branch: Tag:

2017-09-12

2017-09-12 09:56:13 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Stdio.File: Don't preallocate huge read buffers.

It is common for code to attempt to read huge (typically on
the order of 2GB) amounts of data from sources which are
expected to be much smaller. Don't fail the read() due to
there being no memory for the huge buffer.

Fixes multiple build failures.

744:    THREADS_ALLOW();       while (count) { -  size_t len = count; +  size_t len = MINIMUM(DIRECT_BUFSIZE, count);    ptrdiff_t bytes_read;       /* make space for exactly len bytes plus the terminating null byte. */
997:    THREADS_ALLOW();       while (count) { -  size_t len = count; +  size_t len = MINIMUM(DIRECT_BUFSIZE, count);       /* make space for exactly len bytes plus the terminating null byte */    /* as long as count comes from pike, it was signed, i.e. len+1 is safe */