Mixer: Cope with some plugins having insane numbers of parameters.

This commit is contained in:
Jonathan Moore Liles 2021-01-23 22:21:40 -08:00
parent e909d9594b
commit 0f8017a1ef
3 changed files with 22 additions and 15 deletions

View File

@ -710,18 +710,21 @@ Module::chain ( Chain *v )
char *
Module::get_parameters ( void ) const
{
char *s = new char[1024];
int len = control_input.size() * 50;
char *s = new char[ len ];
s[0] = 0;
char *sp = s;
if ( control_input.size() )
{
for ( unsigned int i = 0; i < control_input.size(); ++i )
sp += snprintf( sp, 1024 - (sp - s),"%f:", control_input[i].control_value() );
sp += snprintf( sp, len - (sp - s),"%f:", control_input[i].control_value() );
*(sp - 1) = '\0';
}
/* DMESSAGE("get_parameters: %s",s); */
return s;
}

View File

@ -94,7 +94,6 @@ unescape ( char *s )
char *
Log_Entry::print ( void ) const
{
/* FIXME: gross over-allocation */
char *r = (char*)malloc( 1024 );
r[0] = 0;
@ -105,20 +104,17 @@ Log_Entry::print ( void ) const
get( i, &s, &v );
/* FIXME: arbitrary limit */
char t[1024];
snprintf( t, sizeof( t ), "%s %s%s", s, v, size() == i + 1 ? "" : " " );
char *t;
asprintf( &t, "%s %s%s", s, v, size() == i + 1 ? "" : " " );
r = (char*)realloc( r, strlen(r) + strlen(t) + 1 );
strcat( r, t );
free(t);
}
char *r2 = (char*)malloc( strlen( r ) + 1 );
strcpy( r2, r );
free( r );
return r2;
return r;
}
/** sigh. parse a string of ":name value :name value" pairs into an

View File

@ -346,10 +346,18 @@ Loggable::update_id ( unsigned int id )
const char *
Loggable::escape ( const char *s )
{
static char r[512];
static size_t rl = 256;
static char *r = new char[rl + 1];
if ( strlen(s) * 2 > rl )
{
delete []r;
rl = strlen(s) * 2;
r = new char[ rl + 1 ];
}
size_t i = 0;
for ( ; *s && i < sizeof( r ); ++i, ++s )
for ( ; *s && i < rl; ++i, ++s )
{
if ( '\n' == *s )
{