Fix fread/fwrite zero division when size is zero.

This commit is contained in:
Jonas 'Sortie' Termansen 2015-11-21 01:08:36 +01:00
parent 0100b61855
commit b8f12a6856
2 changed files with 4 additions and 0 deletions

View File

@ -40,6 +40,8 @@ size_t fread_unlocked(void* ptr,
unsigned char* buf = (unsigned char*) ptr;
size_t count = element_size * num_elements;
if ( count == 0 )
return num_elements;
if ( fp->buffer_mode == _IONBF )
{

View File

@ -40,6 +40,8 @@ size_t fwrite_unlocked(const void* ptr,
const unsigned char* buf = (const unsigned char*) ptr;
size_t count = element_size * num_elements;
if ( count == 0 )
return num_elements;
if ( fp->buffer_mode == _IONBF )
{