Currently, Pd segfaults if the "makefilename" object is configured to receive a symbol ("%s") and it receives a float argument.
This patch uses strstr() to check if the sprintf string is going to accept a float, like so:
strstr(s->s_name, "%s")==0
The result is saved in the t_makefilename structure. It is recalculated on the "set" message.
When the wrong message type is received, a 0 or "" string is substituted, respectfully.
While it is unfortunate to do a string search like this, it is not very good to have Pd segfaulting, so I see no alternative.
Anonymous
Logged In: YES
user_id=27104
Originator: NO
I applied this patch to the Pd-0.39.2-extended branch and it failed to compile:
x_connective.c: In function 'makefilename_new':
x_connective.c:1213: error: 'struct _makefilename' has no member named 'x_accept_float'
x_connective.c: In function 'makefilename_float':
x_connective.c:1219: error: 'struct _makefilename' has no member named 'x_accept_float'
x_connective.c: In function 'makefilename_symbol':
x_connective.c:1229: error: 'struct _makefilename' has no member named 'x_accept_float'
x_connective.c: In function 'makefilename_set':
x_connective.c:1239: error: 'struct _makefilename' has no member named 'x_accept_float'
My guess is that the patch needs to be a "diff -uw" format, which is much better at dealing with different line numbers, etc.
Also, an example patch to demonstrate the bug is always useful.
Logged In: YES
user_id=313747
Originator: NO
It would take more work to do it right: check that
there's only one "%f" and no "%s" or vice versa,
and further check for "%%f", etc... I figure on
doing this someday if nobody else does.
Example patch showing how to crash [makefilename].
Logged In: YES
user_id=616837
Originator: YES
File Added: makefilename_crash.pd
A more complete patch scanning the makefilename symbol argument for sprintf-compatible types.
Logged In: YES
user_id=616837
Originator: YES
Attached is a more complete patch scanning the symbol argument more thoroughly for sprintf-compatible formatting. Also now differentiates between float and int arguments, and supports format flags. Could probably be extended to support multiple arguments.
This patch also stops makefilename from spitting out (null) symbols.
Patch generated with "diff -uw x_connective.c"
File Added: makefilename_scanformat.patch
Logged In: YES
user_id=27104
Originator: NO
Does this new patch replace pd-cvs-makefilename-20070326.patch? If so, pd-cvs-makefilename-20070326.patch should be deleted from this tracker.
I committed it to packages/patches so it'll be automatically included in the Pd-0.40.3-extended nightly builds.
Logged In: YES
user_id=616837
Originator: YES
Deleting original patch as requested.
pd-cvs-makefilename-20070326.patch is replaced by makefilename_scanformat.patch
Logged In: YES
user_id=313747
Originator: NO
taken.