1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
From: =?utf-8?b?0L3QsNCx?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Sun, 23 Feb 2025 03:24:17 +0100
Subject: Don't return dangling pointer from snd()
---
src/festival.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/festival.c b/src/festival.c
index f33b22e..78781c0 100644
--- a/src/festival.c
+++ b/src/festival.c
@@ -73,23 +73,20 @@ static void on_prepend_who_checkbutton_clicked(GtkWidget *widget, void *data);
static void on_replace_url_checkbutton_clicked(GtkWidget *widget, void *data);
static void on_announce_events_checkbutton_clicked(GtkWidget *widget, void *data);
-static char * snd(char * sndType);
G_GNUC_CONST static gint badchar(char c);
static char *unlinkify_text(const char *text);
/*---------Functions---------------------*/
/** This function needs to be better written **/
-static char * snd(char * sndType) {
+static void snd(const char * sndType, char * daemon) {
- char *daemon = "";
if (strcmp (sndType, "arts") == 0 ||
strcmp (sndType, "esd") == 0 ||
strcmp (sndType, "alsa") == 0 ||
strcmp (sndType, "automatic") == 0) {
FILE *which_pf;
- char sndserver[1024];
if (strcmp (sndType, "arts") == 0)
which_pf= popen("command -v artsdsp","r");
else if (strcmp (sndType, "esd") == 0)
@@ -98,14 +95,13 @@ static char * snd(char * sndType) {
which_pf= popen("command -v aoss","r");
else if (strcmp (sndType, "automatic") == 0)
which_pf= popen("command -v artsdsp","r");
- fscanf(which_pf,"%1023s",sndserver);
+ fscanf(which_pf,"%1023s",daemon);
pclose(which_pf);
- daemon=sndserver;
}
else{
purple_debug(PURPLE_DEBUG_INFO, "pidgin festival sound method ","%s", sndType);
+ daemon[0] = '\0';
}
- return daemon;
}
G_GNUC_CONST static gint badchar(char c)
@@ -531,7 +527,9 @@ plugin_load(PurplePlugin *plugin) {
return FALSE;
char proc[1024];
- snprintf(proc,1024, "%s %s", snd((char *)purple_prefs_get_string("/pidgin/sound/method")), line);
+ snd((char *)purple_prefs_get_string("/pidgin/sound/method"), proc);
+ strcat(proc, " ");
+ strcat(proc, line);
purple_debug(PURPLE_DEBUG_INFO, "pidgin festival","%s", proc);
festival_pf= popen(proc,"w");
|