From c7837f0e5956e751c43f909436a6365386ffb472 Mon Sep 17 00:00:00 2001 From: YohanPipereau Date: Thu, 6 Jun 2019 19:30:16 +0200 Subject: Correct a memory leak and an unused value Change-Id: I40ca7b6017731b165c87a0653f40eb4d3cfaa22c Signed-off-by: YohanPipereau --- src/scvpp/inc/scvpp/comm.h | 5 ++++- src/scvpp/src/comm.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/scvpp') diff --git a/src/scvpp/inc/scvpp/comm.h b/src/scvpp/inc/scvpp/comm.h index da83fa7..ed02d5d 100644 --- a/src/scvpp/inc/scvpp/comm.h +++ b/src/scvpp/inc/scvpp/comm.h @@ -137,8 +137,11 @@ static inline int push(struct elt **stack, void *data, int length) if (!el) return -ENOMEM; el->data = malloc(length); - if (!el->data) + if (!el->data) { + free(el); return -ENOMEM; + } + memcpy(el->data, data, length); if (*stack) diff --git a/src/scvpp/src/comm.c b/src/scvpp/src/comm.c index 532ee1e..b679880 100644 --- a/src/scvpp/src/comm.c +++ b/src/scvpp/src/comm.c @@ -32,6 +32,10 @@ int sc_connect_vpp() if (g_vapi_ctx == NULL) { vapi_error_e rv = vapi_ctx_alloc(&g_vapi_ctx); + if (rv != VAPI_OK) { + g_vapi_ctx = NULL; + return -1; + } rv = vapi_connect(g_vapi_ctx, APP_NAME, NULL, MAX_OUTSTANDING_REQUESTS, RESPONSE_QUEUE_SIZE, VAPI_MODE_BLOCKING, true); -- cgit 1.2.3-korg