Skip to content

Commit

Permalink
Fix coverity #292159
Browse files Browse the repository at this point in the history
Signed-off-by: Stefano Babic <[email protected]>
  • Loading branch information
sbabic committed Apr 21, 2020
1 parent e4b554a commit 083207e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/installer.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,13 @@ int install_single_image(struct img_type *img, int dry_run)
int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)
{
int ret;
struct img_type *img;
struct img_type *img, *tmp;
char *filename;
struct filehdr fdh;
struct stat buf;
const char* TMPDIR = get_tmpdir();
int dry_run = sw->globals.dry_run;
bool dropimg;

/* Extract all scripts, preinstall scripts must be run now */
const char* tmpdir_scripts = get_tmpdirscripts();
Expand All @@ -280,7 +281,9 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)
}
}

LIST_FOREACH(img, &sw->images, next) {
LIST_FOREACH_SAFE(img, &sw->images, next, tmp) {

dropimg = false;

/*
* If image is flagged to be installed from stream
Expand Down Expand Up @@ -336,7 +339,7 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)
break;
}
}
free_image(img);
dropimg = true;
ret = 0;
} else {
ret = install_single_image(img, dry_run);
Expand All @@ -345,9 +348,11 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)
if (!fromfile)
close(img->fdin);

if (dropimg)
free_image(img);

if (ret)
return ret;

}

/*
Expand Down

0 comments on commit 083207e

Please sign in to comment.