From: Peter Stuge Date: Sat, 3 Nov 2012 07:27:48 +0000 (+0100) Subject: backend.c: Fix memory leak in sr_init() error path X-Git-Tag: dsupstream~473 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=123d97b17715204c58b795b8e6cbecc55725e5d3;p=libsigrok.git backend.c: Fix memory leak in sr_init() error path Commit 785b9ff290cbdb86e7d0b0280c33b43faf9c0518 added libusb init into sr_init() which can generate an error. In this case, the already allocated struct sr_context would have leaked. --- diff --git a/backend.c b/backend.c index 22f65a7c..f596c96e 100644 --- a/backend.c +++ b/backend.c @@ -249,9 +249,12 @@ SR_API int sr_init(struct sr_context **ctx) #endif *ctx = context; + context = NULL; ret = SR_OK; done: + if (context) + g_free(context); return ret; }