-/* $OpenBSD: bsd-comp.c,v 1.11 2015/07/15 22:16:41 deraadt Exp $ */
+/* $OpenBSD: bsd-comp.c,v 1.12 2015/10/07 18:29:35 deraadt Exp $ */
/* $NetBSD: bsd-comp.c,v 1.6 1996/10/13 02:10:58 christos Exp $ */
/* Because this code is derived from the 4.3BSD compress source:
db->lens = mallocarray(maxmaxcode + 1, sizeof(db->lens[0]), M_DEVBUF,
M_NOWAIT);
if (!db->lens) {
- free(db, M_DEVBUF, 0);
+ free(db, M_DEVBUF, newlen);
return NULL;
}
}
struct bsd_db *db = (struct bsd_db *) state;
if (db->lens)
- free(db->lens, M_DEVBUF, 0);
- free(db, M_DEVBUF, 0);
+ free(db->lens, M_DEVBUF, (db->maxmaxcode + 1) * sizeof(db->lens[0]));
+ free(db, M_DEVBUF, db->totlen);
}
static void *