diff options
author | Niall O'Higgins <niallo@cvs.openbsd.org> | 2006-01-16 21:02:37 +0000 |
---|---|---|
committer | Niall O'Higgins <niallo@cvs.openbsd.org> | 2006-01-16 21:02:37 +0000 |
commit | e50223e155d05a9c47901f6fcf569f862ea8e876 (patch) | |
tree | 7a7c45a46ef0bf336c47245c5276915f247f8158 | |
parent | 83a069bfe3ba9c5cc7a405b02c73d865f61d54f1 (diff) |
- in cvs_buf_free(), don't try to free() b->cb_buf if it has not been
allocated. fixes PR4974.
From: <ttakah@lapis.plala.or.jp>
-rw-r--r-- | usr.bin/cvs/buf.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c index 488a1cbebe1..5120fc90ca8 100644 --- a/usr.bin/cvs/buf.c +++ b/usr.bin/cvs/buf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.c,v 1.30 2006/01/15 19:25:32 niallo Exp $ */ +/* $OpenBSD: buf.c,v 1.31 2006/01/16 21:02:36 niallo Exp $ */ /* * Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -66,7 +66,8 @@ cvs_buf_alloc(size_t len, u_int flags) if (len > 0) { b->cb_buf = xmalloc(len); memset(b->cb_buf, 0, len); - } + } else + b->cb_buf = NULL; b->cb_flags = flags; b->cb_size = len; @@ -125,7 +126,8 @@ cvs_buf_load(const char *path, u_int flags) void cvs_buf_free(BUF *b) { - xfree(b->cb_buf); + if (b->cb_buf != NULL) + xfree(b->cb_buf); xfree(b); } |