backend.c: Fix memory leak in sr_init() error path

Commit 785b9ff290 added libusb init into
sr_init() which can generate an error. In this case, the already
allocated struct sr_context would have leaked.
This commit is contained in:
Peter Stuge 2012-11-03 08:27:48 +01:00
parent 1740429d70
commit 123d97b177
1 changed files with 3 additions and 0 deletions

View File

@ -249,9 +249,12 @@ SR_API int sr_init(struct sr_context **ctx)
#endif #endif
*ctx = context; *ctx = context;
context = NULL;
ret = SR_OK; ret = SR_OK;
done: done:
if (context)
g_free(context);
return ret; return ret;
} }