add checking code for fwrite, problem reported by Michal Marek

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8472 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-01-17 00:52:34 +00:00
commit cbf3800960

View file

@ -71,7 +71,9 @@ static int
File_write(DOH *fo, void *buffer, int len) {
DohFile *f = (DohFile *) ObjData(fo);
if (f->filep) {
return fwrite(buffer,1,len,f->filep);
int ret = (int) fwrite(buffer, 1, len, f->filep);
int err = (ret != len) ? ferror(f->filep) : 0;
return err ? -1: ret;
} else if (f->fd) {
#ifdef DOH_INTFILE
return write(f->fd,buffer,len);