From 41d1dcc0299ffe54da1913fa232d4a87b01ef3c8 Mon Sep 17 00:00:00 2001 From: Brian Collins <60075820+bcollins526@users.noreply.github.com> Date: Sun, 19 Jan 2020 13:06:11 -0800 Subject: [PATCH] changed buffer to path for STB_EXT_NO_PERIOD, and specified appropriate buffer size for the copy (sizeof(buffer) referred to the size of the buffer pointer, which was incorrect) --- stb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stb.h b/stb.h index a853d08..e275d5a 100644 --- a/stb.h +++ b/stb.h @@ -2439,7 +2439,7 @@ static char *stb__splitpath_raw(char *buffer, char *path, int flag) } else { x = f2; if (flag & STB_EXT_NO_PERIOD) - if (buffer[x] == '.') + if (path[x] == '.') ++x; } @@ -2456,7 +2456,7 @@ static char *stb__splitpath_raw(char *buffer, char *path, int flag) } if (len) { stb_p_strcpy_s(buffer, sizeof(buffer), "./"); return buffer; } - stb_p_strncpy_s(buffer, sizeof(buffer),path+x, y-x); + stb_p_strncpy_s(buffer, y-x+1, path+x, y-x); buffer[y-x] = 0; return buffer; }