mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-20 04:21:11 +01:00
safer extension list construction
1016 didn't fix anything (just caused skipping over every other ext). Winamp's issue was fixed in 5.666.
This commit is contained in:
parent
8a618d7a3d
commit
a095da3965
24
src/util.c
24
src/util.c
@ -161,7 +161,29 @@ void concatn_doublenull(int length, char * dst, const char * src) {
|
||||
return;
|
||||
}
|
||||
if (i>0) i++;
|
||||
for (j=0;i<length-2 && src[j];i++,j++) dst[i]=src[j];
|
||||
for (j=0;i<length-2 && (src[j] || src[j+1]);i++,j++) dst[i]=src[j];
|
||||
dst[i]='\0';
|
||||
dst[i+1]='\0';
|
||||
}
|
||||
|
||||
/* length is maximum length of dst. dst will always be double-null-terminated if
|
||||
* length > 1, if src won't fit, truncate */
|
||||
void concatn_fitting_doublenull(int length, char * dst, const char * src) {
|
||||
int i,j,k;
|
||||
if (length <= 1) return;
|
||||
for (i=0;i<length-2 && (dst[i] || dst[i+1]);i++); /* find end of dst */
|
||||
if (i==length-2) {
|
||||
dst[i]='\0';
|
||||
dst[i+1]='\0';
|
||||
return;
|
||||
}
|
||||
if (i>0) i++;
|
||||
k = i;
|
||||
for (j=0;i<length-2 && (src[j] || src[j+1]);i++,j++) dst[i]=src[j];
|
||||
|
||||
if (i == length-2 && (src[j] || src[j+1])) {
|
||||
i = k;
|
||||
}
|
||||
dst[i]='\0';
|
||||
dst[i+1]='\0';
|
||||
}
|
||||
|
@ -67,5 +67,6 @@ void swap_samples_le(sample *buf, int count);
|
||||
|
||||
void concatn(int length, char * dst, const char * src);
|
||||
void concatn_doublenull(int length, char * dst, const char * src);
|
||||
void concatn_fitting_doublenull(int length, char * dst, const char * src);
|
||||
|
||||
#endif
|
||||
|
@ -373,7 +373,7 @@ void build_extension_list() {
|
||||
working_extension_list[1]='\0';
|
||||
|
||||
for (i=0;i<sizeof(extension_list)/sizeof(extension_list[0]);i++) {
|
||||
concatn_doublenull(EXTENSION_LIST_SIZE,working_extension_list,
|
||||
concatn_fitting_doublenull(EXTENSION_LIST_SIZE,working_extension_list,
|
||||
extension_list[i]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user