From bc07938965efeb07b0446f893eb8d825f90b5379 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 8 Jun 2009 21:57:56 +0000 Subject: [PATCH] (emem_trunc): if offset is NULL, free all memory git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25281 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/store_emem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/krb5/store_emem.c b/lib/krb5/store_emem.c index 4be89b656..acf984280 100644 --- a/lib/krb5/store_emem.c +++ b/lib/krb5/store_emem.c @@ -110,7 +110,12 @@ emem_trunc(krb5_storage *sp, off_t offset) * If offset is larget then current size, or current size is * shrunk more then half of the current size, adjust buffer. */ - if (offset > s->size || (s->size / 2) > offset) { + if (offset == 0) { + free(s->base); + s->size = 0; + s->base = NULL; + s->ptr = NULL; + } else if (offset > s->size || (s->size / 2) > offset) { void *base; size_t off; off = s->ptr - s->base; -- 2.11.4.GIT