Skip to content

Commit e4856ad

Browse files
committed
bug: resolve some CodeQL defects
1 parent 46a06fd commit e4856ad

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,7 @@ static struct timeval *vet_age(const char *t, int *subonly)
781781
} else if (!strcmp(tmp, "w")) {
782782
val = (uint64_t)ret * 1000000 * 60 * 60 * 24 * 7;
783783
} else {
784-
if (tmp)
785-
free(tmp);
784+
free(tmp);
786785
warnx("vet_age: invalid age: %s\n", t);
787786
return NULL;
788787
}
@@ -1166,6 +1165,11 @@ static int rm_rf(const char *path, const struct timeval *tv,
11661165
return -1;
11671166

11681167
/* remove the directory itself when appropriate */
1168+
if (lstat(path, &sb) == -1) {
1169+
warn("rm_rf: lstat(%s)", path);
1170+
return -1;
1171+
}
1172+
11691173
if (!tv || (time(NULL) - sb.st_mtime) > tv->tv_sec) {
11701174
if (rmdir(path) == -1 && errno != ENOTEMPTY && errno != EEXIST) {
11711175
warn("rm_rf: rmdir(%s)", path);

0 commit comments

Comments
 (0)