roken: rk_undumpdata free allocation on error

Do not return allocated memory and an error code.
Free it instead so as to avoid memory leaks.

Change-Id: I47d42be0f6bc52062c57c00c37b665ee2f2811ce
This commit is contained in:
Jeffrey Altman
2016-11-19 02:08:58 -05:00
parent d8e7027c9d
commit 2f62c7c77e

View File

@@ -81,14 +81,16 @@ rk_undumpdata(const char *filename, void **buf, size_t *size)
sret = net_read(fd, *buf, *size);
if (sret < 0)
ret = errno;
else if (sret != (ssize_t)*size) {
else if (sret != (ssize_t)*size)
ret = EINVAL;
free(*buf);
*buf = NULL;
} else
else
ret = 0;
out:
if (ret) {
free(*buf);
*buf = NULL;
}
close(fd);
return ret;
}