Fixes: f3d911463e8 "util/disk_cache: stop using ralloc_asprintf() unnecessarily"
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
char *filename;
_mesa_sha1_format(buf, key);
char *filename;
_mesa_sha1_format(buf, key);
- asprintf(&filename, "%s/%c%c/%s", cache->path, buf[0], buf[1], buf + 2);
+ if (asprintf(&filename, "%s/%c%c/%s", cache->path, buf[0],
+ buf[1], buf + 2) == -1)
+ return NULL;
char buf[41];
_mesa_sha1_format(buf, key);
char buf[41];
_mesa_sha1_format(buf, key);
- asprintf(&dir, "%s/%c%c", cache->path, buf[0], buf[1]);
- mkdir_if_needed(dir);
+ if (asprintf(&dir, "%s/%c%c", cache->path, buf[0], buf[1]) == -1)
+ return;
* final destination filename, (to prevent any readers from seeing
* a partially written file).
*/
* final destination filename, (to prevent any readers from seeing
* a partially written file).
*/
- asprintf(&filename_tmp, "%s.tmp", filename);
- if (filename_tmp == NULL)
+ if (asprintf(&filename_tmp, "%s.tmp", filename) == -1)
goto done;
fd = open(filename_tmp, O_WRONLY | O_CLOEXEC | O_CREAT, 0644);
goto done;
fd = open(filename_tmp, O_WRONLY | O_CLOEXEC | O_CREAT, 0644);