mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-29 14:42:11 +01:00
43790: failed mailstat could leak memory
This commit is contained in:
parent
e27175c7c8
commit
d50e204b0c
2 changed files with 15 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
|||
2018-11-09 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 43790: Kamil: Src/utils.c: failed mailstat could leak memory.
|
||||
|
||||
* 43789: Kamil: Src/module.c: possible use after free handling
|
||||
math functions from module.
|
||||
|
||||
|
|
16
Src/utils.c
16
Src/utils.c
|
@ -7459,19 +7459,28 @@ mailstat(char *path, struct stat *st)
|
|||
|
||||
/* See if cur/ is present */
|
||||
dir = appstr(ztrdup(path), "/cur");
|
||||
if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
|
||||
if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) {
|
||||
zsfree(dir);
|
||||
return 0;
|
||||
}
|
||||
st_ret.st_atime = st_tmp.st_atime;
|
||||
|
||||
/* See if tmp/ is present */
|
||||
dir[plen] = 0;
|
||||
dir = appstr(dir, "/tmp");
|
||||
if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
|
||||
if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) {
|
||||
zsfree(dir);
|
||||
return 0;
|
||||
}
|
||||
st_ret.st_mtime = st_tmp.st_mtime;
|
||||
|
||||
/* And new/ */
|
||||
dir[plen] = 0;
|
||||
dir = appstr(dir, "/new");
|
||||
if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) return 0;
|
||||
if (stat(dir, &st_tmp) || !S_ISDIR(st_tmp.st_mode)) {
|
||||
zsfree(dir);
|
||||
return 0;
|
||||
}
|
||||
st_ret.st_mtime = st_tmp.st_mtime;
|
||||
|
||||
#if THERE_IS_EXACTLY_ONE_MAILDIR_IN_MAILPATH
|
||||
|
@ -7483,6 +7492,7 @@ mailstat(char *path, struct stat *st)
|
|||
st_tmp.st_atime == st_new_last.st_atime &&
|
||||
st_tmp.st_mtime == st_new_last.st_mtime) {
|
||||
*st = st_ret_last;
|
||||
zsfree(dir);
|
||||
return 0;
|
||||
}
|
||||
st_new_last = st_tmp;
|
||||
|
|
Loading…
Reference in a new issue