[LEDE-DEV] [PATCH 4/4] otrx: fix memory leak in otrx_create_append_zeros
rosenp at gmail.com
rosenp at gmail.com
Thu Nov 16 02:31:57 PST 2017
On Thu, 2017-11-16 at 10:15 +0100, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal at milecki.pl>
>
> A "free" call was missing after allocating a buffer.
>
> Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
> ---
> package/utils/otrx/src/otrx.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/package/utils/otrx/src/otrx.c
> b/package/utils/otrx/src/otrx.c
> index 1c3ffd915b..ac39fefc06 100644
> --- a/package/utils/otrx/src/otrx.c
> +++ b/package/utils/otrx/src/otrx.c
> @@ -266,9 +266,12 @@ static ssize_t otrx_create_append_zeros(FILE
> *trx, size_t length) {
>
> if (fwrite(buf, 1, length, trx) != length) {
> fprintf(stderr, "Couldn't write %zu B to %s\n",
> length, trx_path);
> + free(buf);
> return -EIO;
> }
>
> + free(buf);
alternatively, could do
unsigned int l = fwrite(buf, 1, length, trx);
free(buf);
if (l != length) {
...
no real difference.
> +
> return length;
> }
>
More information about the Lede-dev
mailing list