libc: fwrite: bail quickly if size calcs to 0

This commit is contained in:
K. Lange 2018-10-12 13:50:53 +09:00
parent e492f967c0
commit 5de060b1d5

View File

@ -319,6 +319,8 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE * stream) {
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE * stream) { size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE * stream) {
size_t out_size = size * nmemb; size_t out_size = size * nmemb;
if (!out_size) return 0;
int r = syscall_write(stream->fd, (void*)ptr, out_size); int r = syscall_write(stream->fd, (void*)ptr, out_size);
if (r < 0) { if (r < 0) {
errno = -r; errno = -r;