From c6a506808f37cf7a9f4ba049e89e9fad38435899 Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Tue, 8 Oct 2024 02:43:10 +0200
Subject: [PATCH] Fix crash during creation of fiddle~.

Made the fiddle~ message callbacks and sigfiddle_new static, otherwise
instantiation would crash because of a bogus NULL class pointer
(although sigfiddle_class is surely initialized, otherwise sigfiddle_new
could never be called in the first place).

The other stuff in pd/extra seems to be fine, all methods there are
static already, but I haven't checked all the externals.

Observed on Arch with gcc 14.2.1 20240910, Mac and Windows builds seem
to be fine. To me this looks like a compiler or linker bug for that
specific gcc version.  (Come on, Arch, are we now getting compiler
versions from git that haven't been released yet and presumably still
need testing? Who thought that this would be a good idea?)
---
 pd/extra/fiddle~/fiddle~.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pd/extra/fiddle~/fiddle~.c b/pd/extra/fiddle~/fiddle~.c
index 7e2fa8e76..be95453e9 100644
--- a/pd/extra/fiddle~/fiddle~.c
+++ b/pd/extra/fiddle~/fiddle~.c
@@ -1412,7 +1412,7 @@ nono:
     return (w+4);
 }
 
-void sigfiddle_dsp(t_sigfiddle *x, t_signal **sp)
+static void sigfiddle_dsp(t_sigfiddle *x, t_signal **sp)
 {
     x->x_sr = sp[0]->s_sr;
     sigfiddle_reattack(x, x->x_attacktime, x->x_attackthresh);
@@ -1424,7 +1424,7 @@ void sigfiddle_dsp(t_sigfiddle *x, t_signal **sp)
     the "bang" method; you can leave "auto" on to get this called
     automatically (the default) or turn auto off and bang it yourself. */
 
-void sigfiddle_bang(t_sigfiddle *x)
+static void sigfiddle_bang(t_sigfiddle *x)
 {
     int i;
     t_pitchhist *ph;
@@ -1454,7 +1454,7 @@ void sigfiddle_bang(t_sigfiddle *x)
         if (ph->h_pitch) outlet_float(x->x_noteout, ph->h_pitch);
 }
 
-void sigfiddle_ff(t_sigfiddle *x)               /* cleanup on free */
+static void sigfiddle_ff(t_sigfiddle *x)               /* cleanup on free */
 {
     if (x->x_inbuf)
     {
@@ -1468,7 +1468,7 @@ void sigfiddle_ff(t_sigfiddle *x)               /* cleanup on free */
 
 static t_class *sigfiddle_class;
 
-void *sigfiddle_new(t_floatarg npoints, t_floatarg npitch,
+static void *sigfiddle_new(t_floatarg npoints, t_floatarg npitch,
     t_floatarg fnpeakanal, t_floatarg fnpeakout)
 {
     t_sigfiddle *x = (t_sigfiddle *)pd_new(sigfiddle_class);
-- 
GitLab