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:
Christian Brueffer 2014-04-14 21:02:20 +00:00
parent 9653775e6b
commit 83a396ce95
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=264471

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;
}