This commit is contained in:
Kovid Goyal 2021-04-27 15:11:34 +05:30
parent 2178ff1c48
commit fc184984a0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -85,7 +85,7 @@ static int
open_cache_file_without_tmpfile(const char *cache_path) { open_cache_file_without_tmpfile(const char *cache_path) {
int fd = -1; int fd = -1;
static const char *template = "%s/disk-cache-XXXXXXXXXXXX"; static const char *template = "%s/disk-cache-XXXXXXXXXXXX";
size_t sz = strlen(cache_path) + sizeof(template); const size_t sz = strlen(cache_path) + sizeof(template) + 4;
FREE_AFTER_FUNCTION char *buf = calloc(1, sz); FREE_AFTER_FUNCTION char *buf = calloc(1, sz);
if (!buf) { errno = ENOMEM; return -1; } if (!buf) { errno = ENOMEM; return -1; }
snprintf(buf, sz - 1, template, cache_path); snprintf(buf, sz - 1, template, cache_path);