summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-04-20 17:59:14 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-04-21 22:03:29 -0700
commitc77a0784bdfc8c178f0742689cf6ae02a2fce37f (patch)
tree6ecf8b712d53786fa19ac5a2e8e2503b3ad2ef6d
parentc8855746aec2a9b732502da0ca3258b4e701c61a (diff)
Check if pointer returned by BufFileCreate is NULL before writing to it
Fixes clang analyzer warning: bufio.c:165:13: warning: Access to field 'bufp' results in a dereference of a null pointer (loaded from variable 'f') f->bufp = f->buffer; ~ ^ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Thomas Klausner <wiz@NetBSD.org>
-rw-r--r--src/fontfile/bufio.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/fontfile/bufio.c b/src/fontfile/bufio.c
index 34b7f36..d8d4f29 100644
--- a/src/fontfile/bufio.c
+++ b/src/fontfile/bufio.c
@@ -162,8 +162,10 @@ BufFileOpenWrite (int fd)
setmode(fd,O_BINARY);
#endif
f = BufFileCreate ((char *)(long) fd, 0, BufFileRawFlush, 0, BufFileFlush);
- f->bufp = f->buffer;
- f->left = BUFFILESIZE;
+ if (f != NULL) {
+ f->bufp = f->buffer;
+ f->left = BUFFILESIZE;
+ }
return f;
}