Skip to content

Commit 8511b53

Browse files
committed
fix compiler warning with slang cache while I'm at it
1 parent 5d84394 commit 8511b53

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

gfx/drivers_shader/slang_cache.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,18 @@ static bool spirv_cache_get_filename(const char *hash,
6464
char *cache_file_out, size_t cache_file_out_len)
6565
{
6666
char cache_dir[PATH_MAX_LENGTH];
67+
int ret;
6768

6869
if (!spirv_cache_get_dir(cache_dir, sizeof(cache_dir)))
6970
return false;
7071

71-
snprintf(cache_file_out, cache_file_out_len, "%s/%s.spirv",
72+
ret = snprintf(cache_file_out, cache_file_out_len, "%s/%s.spirv",
7273
cache_dir, hash);
7374

75+
/* Check if snprintf truncated the output */
76+
if (ret < 0 || (size_t)ret >= cache_file_out_len)
77+
return false;
78+
7479
return true;
7580
}
7681

0 commit comments

Comments
 (0)