aboutsummaryrefslogtreecommitdiff
path: root/pd/src/x_gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'pd/src/x_gui.c')
-rw-r--r--pd/src/x_gui.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/pd/src/x_gui.c b/pd/src/x_gui.c
index e83981bb..2409ca41 100644
--- a/pd/src/x_gui.c
+++ b/pd/src/x_gui.c
@@ -46,6 +46,9 @@ void gfxstub_new(t_pd *owner, void *key, const char *cmd)
{
char buf[4*MAXPDSTRING];
char namebuf[80];
+ char sprintfbuf[MAXPDSTRING];
+ char *afterpercent;
+ t_int afterpercentlen;
t_gfxstub *x;
t_symbol *s;
/* if any exists with matching key, burn it. */
@@ -55,7 +58,7 @@ void gfxstub_new(t_pd *owner, void *key, const char *cmd)
if (strlen(cmd) + 50 > 4*MAXPDSTRING)
{
bug("audio dialog too long");
- bug("%x", cmd);
+ bug("%s", cmd);
return;
}
x = (t_gfxstub *)pd_new(gfxstub_class);
@@ -68,7 +71,13 @@ void gfxstub_new(t_pd *owner, void *key, const char *cmd)
x->x_key = key;
x->x_next = gfxstub_list;
gfxstub_list = x;
- sprintf(buf, cmd, s->s_name);
+ /* only replace first %s so sprintf() doesn't crash */
+ afterpercent = strchr(cmd, '%') + 2;
+ afterpercentlen = afterpercent - cmd;
+ strncpy(sprintfbuf, cmd, afterpercentlen);
+ sprintfbuf[afterpercentlen] = '\0';
+ sprintf(buf, sprintfbuf, s->s_name);
+ strncat(buf, afterpercent, (4*MAXPDSTRING) - afterpercentlen);
sys_gui(buf);
}