Fix svace-reported issues 50/234650/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 27 May 2020 20:40:54 +0000 (22:40 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 27 May 2020 20:45:09 +0000 (22:45 +0200)
Change-Id: I3cf61033c7282d5d89c794e1e25cd4f1988be6e7

lib/scanctx.c

index 5378eb5..42d584e 100644 (file)
@@ -127,9 +127,14 @@ const char *scanctx_getpath(struct scan_context *ctx)
   const char *full_path = NULL;
 
   name = scanctx_take_string(ctx);
+  if(!name)
+    return NULL;
+
   if((name[0] != FILE_SEPARATOR[0]) && ctx->config->include_dir)
   {
     full_path = scanctx_filename(ctx, ctx->config->include_dir, name);
+    if(!full_path)
+      return NULL;
     free((void*)name);
   }
   else
@@ -145,6 +150,8 @@ const char *scanctx_filename(struct scan_context *ctx,const char* dirname, const
 {
   const char *basedir = dirname ? dirname : ctx->basedir;
   char *full_file = (char *)malloc(strlen(basedir) + strlen(filename) + 2);
+  if(!full_file)
+    return NULL;
 
   strcpy(full_file, basedir);
   strcat(full_file, FILE_SEPARATOR);