mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 20:20:11 +02:00
Fix non-const stack allocated arrays in libmodplug.
This commit is contained in:
@@ -2244,11 +2244,11 @@ static void abc_preprocess(ABCHANDLE *h, ABCMACRO *m)
|
|||||||
if( m->n ) {
|
if( m->n ) {
|
||||||
k = m->n - m->name;
|
k = m->n - m->name;
|
||||||
for( i=0; i<14; i++ ) {
|
for( i=0; i<14; i++ ) {
|
||||||
char t[strlen(m->name) + 1];
|
char *t = (char *)malloc(strlen(m->name) + 1);
|
||||||
strcpy(t, m->name);
|
strcpy(t, m->name);
|
||||||
t[k] = "CDEFGABcdefgab"[i];
|
t[k] = "CDEFGABcdefgab"[i];
|
||||||
l = strlen(m->subst);
|
l = strlen(m->subst);
|
||||||
char s[2 * l + 1];
|
char *s = (char *)malloc(2 * l + 1);
|
||||||
char *p = s;
|
char *p = s;
|
||||||
for( j=0; j<l; j++ ) {
|
for( j=0; j<l; j++ ) {
|
||||||
a = m->subst[j];
|
a = m->subst[j];
|
||||||
@@ -2265,6 +2265,8 @@ static void abc_preprocess(ABCHANDLE *h, ABCMACRO *m)
|
|||||||
}
|
}
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
abc_substitute(h, t, s);
|
abc_substitute(h, t, s);
|
||||||
|
free(s);
|
||||||
|
free(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user