summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/xfile.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/source3/lib/xfile.c b/source3/lib/xfile.c
index 503e8c8359..8824ca2c3c 100644
--- a/source3/lib/xfile.c
+++ b/source3/lib/xfile.c
@@ -259,7 +259,7 @@ int x_fflush(XFILE *f)
return -1;
}
- if (f->bufused == 0) return 0;
+ if (f->bufused == 0 || !f->buf) return 0;
ret = write(f->fd, f->buf, f->bufused);
if (ret == -1) return -1;
@@ -267,9 +267,7 @@ int x_fflush(XFILE *f)
f->bufused -= ret;
if (f->bufused > 0) {
f->flags |= X_FLAG_ERROR;
- if (f->buf) {
- memmove(f->buf, ret + (char *)f->buf, f->bufused);
- }
+ memmove(f->buf, ret + (char *)f->buf, f->bufused);
return -1;
}