[Mesa-dev] [PATCH] util/disk_cache: fix d7b3707c612
Manolova, Plamena
plamena.manolova at intel.com
Mon Feb 13 09:07:05 UTC 2017
Reviewed-by: Plamena Manolova <plamena.manolova at intel.com>
On Sat, Feb 11, 2017 at 1:32 PM, Timothy Arceri <tarceri at itsqueeze.com>
wrote:
> I forgot to error check stat() and also I wasn't using the subdir in
> is_two_character_sub_directory().
>
> Cc: Emil Velikov <emil.l.velikov at gmail.com>
> ---
> src/util/disk_cache.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
> index 63954b2..84559ab 100644
> --- a/src/util/disk_cache.c
> +++ b/src/util/disk_cache.c
> @@ -509,10 +509,10 @@ is_regular_non_tmp_file(struct dirent *entry, const
> char *path)
> return false;
>
> struct stat sb;
> - stat(filename, &sb);
> + int res = stat(filename, &sb);
> free(filename);
>
> - if (!S_ISREG(sb.st_mode))
> + if (res == -1 || !S_ISREG(sb.st_mode))
> return false;
>
> size_t len = strlen (entry->d_name);
> @@ -556,10 +556,10 @@ is_two_character_sub_directory(struct dirent
> *entry, const char *path)
> return false;
>
> struct stat sb;
> - stat(path, &sb);
> + int res = stat(subdir, &sb);
> free(subdir);
>
> - if (!S_ISDIR(sb.st_mode))
> + if (res == -1 || !S_ISDIR(sb.st_mode))
> return false;
>
> if (strlen(entry->d_name) != 2)
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170213/fdb9cf33/attachment.html>
More information about the mesa-dev
mailing list