This commit can fix the SVACE issues below.
[SVACE][WGID][259615] DEREF_OF_NULL.RET.ALLOC
[SVACE][WGID][264745] DEREF_OF_NULL.RET.ALLOC
Change-Id: Ida8202a811e34ebddb3557abd43daa3610336179
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
twe_thread*
twe_thread_create(void)
{
- twe_thread *thread;
+ twe_thread *thread = NULL;
+
+ thread = calloc(1, sizeof(twe_thread));
+ if (!thread) {
+ TPL_ERR("Failed to allocate twe_thread");
+ return NULL;
+ }
if (!_twe_ctx) {
GMainContext *context;
+
_twe_ctx = calloc(1, sizeof(twe_thread_context));
+ if (!_twe_ctx) {
+ TPL_ERR("Failed to allocate _twe_ctx");
+ if (thread)
+ free(thread);
+ return NULL;
+ }
context = g_main_context_new();
_twe_ctx->twe_loop = g_main_loop_new(context, FALSE);
_twe_ctx->twe_thread = g_thread_new("twe_thread", _twe_thread_loop,
_twe_ctx);
+ _twe_ctx->ref_cnt = 0;
}
- thread = calloc(1, sizeof(twe_thread));
thread->ctx = _twe_ctx;
_twe_ctx->ref_cnt++;