Browse Source

better to just use stb_strncpy inside stb__splitpath_raw, also fixed an indexing bug in stb_strncpy itself.

Brian Collins 5 years ago
parent
commit
8fca192660
1 changed files with 2 additions and 3 deletions
  1. 2 3
      stb.h

+ 2 - 3
stb.h

@@ -2009,7 +2009,7 @@ char *stb_trimwhite(char *s)
 char *stb_strncpy(char *s, char *t, int n)
 {
    stb_p_strncpy_s(s,n+1,t,n);
-   s[n-1] = 0;
+   s[n] = 0;
    return s;
 }
 
@@ -2457,8 +2457,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, y-x+1, path+x, y-x);
-   buffer[y-x] = 0;
+   stb_strncpy(buffer, path+x, y-x);
    return buffer;
 }