1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-25 22:39:22 +02:00

tools/lib/atnet.c (dialog_vsend): plugged memory leak

This commit is contained in:
Werner Almesberger 2011-04-12 09:32:26 -03:00
parent 95c8fce729
commit 920fe3407f

View File

@ -35,7 +35,7 @@ static int dialog_vsend(struct netio *netio, const char *fmt, va_list ap)
{ {
va_list ap2; va_list ap2;
char *buf; char *buf;
int n; int n, res;
va_copy(ap2, ap); va_copy(ap2, ap);
n = vsnprintf(NULL, 0, fmt, ap2); n = vsnprintf(NULL, 0, fmt, ap2);
@ -49,9 +49,10 @@ static int dialog_vsend(struct netio *netio, const char *fmt, va_list ap)
vsprintf(buf, fmt, ap); vsprintf(buf, fmt, ap);
buf[n] = '\n'; buf[n] = '\n';
if (netio_write(netio, buf, n+1) < 0) res = netio_write(netio, buf, n+1);
return -1; free(buf);
return 0;
return res < 0 ? -1 : 0;
} }