Refine r264422: set buf to NULL only when we don't allocate memory,

and free buf unconditionally.

Requested by:	kib
MFC after:	1 week
This commit is contained in:
brueffer 2014-04-14 21:02:20 +00:00
parent 9ba0aa30f1
commit e3e2951f67

View File

@ -1740,16 +1740,16 @@ __elfN(note_threadmd)(void *arg, struct sbuf *sb, size_t *sizep)
td = (struct thread *)arg;
size = *sizep;
buf = NULL;
if (size != 0 && sb != NULL)
buf = malloc(size, M_TEMP, M_ZERO | M_WAITOK);
else
buf = NULL;
size = 0;
__elfN(dump_thread)(td, buf, &size);
KASSERT(*sizep == size, ("invalid size"));
if (size != 0 && sb != NULL) {
if (size != 0 && sb != NULL)
sbuf_bcat(sb, buf, size);
free(buf, M_TEMP);
}
free(buf, M_TEMP);
*sizep = size;
}