ctx: Avoid potential memory leaks reported by clang

This commit is contained in:
Jakub Jelen 2019-08-26 13:15:02 +02:00 committed by Frank Morgner
parent 14dec11ebd
commit 2f643948f1
1 changed files with 3 additions and 0 deletions

View File

@ -826,6 +826,7 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm)
set_defaults(ctx, &opts);
if (0 != list_init(&ctx->readers)) {
del_drvs(&opts);
sc_release_context(ctx);
return SC_ERROR_OUT_OF_MEMORY;
}
@ -835,6 +836,7 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm)
ctx->thread_ctx = parm->thread_ctx;
r = sc_mutex_create(ctx, &ctx->mutex);
if (r != SC_SUCCESS) {
del_drvs(&opts);
sc_release_context(ctx);
return r;
}
@ -861,6 +863,7 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm)
r = ctx->reader_driver->ops->init(ctx);
if (r != SC_SUCCESS) {
del_drvs(&opts);
sc_release_context(ctx);
return r;
}