From 28369f04b4974092e7fff6d33afeefe4e3a184e1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 28 Aug 2006 03:15:06 +0000 Subject: r17869: More sensible fix for Stanford Checker null deref. Jeremy. (This used to be commit 2a73e82f9663fc0e14b4c2af94de3b4216f1eece) --- source3/lib/xfile.c | 6 ++---- 1 file 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; } -- cgit