Added
Link Here
|
1 |
diff --git a/oggenc/platform.c b/oggenc/platform.c |
2 |
index 6d9f4ef..b66e47a 100644 |
3 |
--- oggenc/platform.c |
4 |
+++ oggenc/platform.c |
5 |
@@ -136,18 +136,22 @@ int create_directories(char *fn, int isutf8) |
6 |
{ |
7 |
char *end, *start; |
8 |
struct stat statbuf; |
9 |
- char *segment = malloc(strlen(fn)+1); |
10 |
+ const size_t fn_len = strlen(fn); |
11 |
+ char *segment = malloc(fn_len+1); |
12 |
#ifdef _WIN32 |
13 |
wchar_t seg[MAX_PATH+1]; |
14 |
#endif |
15 |
|
16 |
start = fn; |
17 |
#ifdef _WIN32 |
18 |
- if(strlen(fn) >= 3 && isalpha(fn[0]) && fn[1]==':') |
19 |
+ // Strip drive prefix |
20 |
+ if(fn_len >= 3 && isalpha(fn[0]) && fn[1]==':') { |
21 |
+ |
22 |
start = start+2; |
23 |
#endif |
24 |
|
25 |
- while((end = strpbrk(start+1, PATH_SEPS)) != NULL) |
26 |
+ // Loop through path segments, creating directories if necessary |
27 |
+ while((end = strpbrk(start + strspn(start, PATH_SEPS), PATH_SEPS)) != NULL) |
28 |
{ |
29 |
int rv; |
30 |
memcpy(segment, fn, end-fn); |