Skip to content

Commit 6436739

Browse files
committed
better null pointer handling
1 parent bd455b8 commit 6436739

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

discord_presence.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ static char * nowplaying_format_string (char * script) {
7070
char * out = malloc(MAX_LEN);
7171
if (out && code_script) {
7272
deadbeef->tf_eval (&context, code_script, out, MAX_LEN);
73+
trace ("nowplaying_format_string: \"%s\"\n",out);
7374
deadbeef->tf_free (code_script);
7475
}
7576
deadbeef->pl_item_unref (nowplaying);
7677
if (nowplaying_plt){
7778
deadbeef->plt_unref (nowplaying_plt);
7879
}
79-
trace ("nowplaying_format_string: \"%s\"\n",out);
8080
return out;
8181
}
8282

@@ -184,9 +184,12 @@ static void updateDiscordPresence(int playback_status, float song_len) {
184184

185185
Discord_UpdatePresence(&discordPresence);
186186

187-
free (title_text);
188-
free (state_text);
189-
free (icon_text);
187+
if (title_text)
188+
free (title_text);
189+
if (state_text)
190+
free (state_text);
191+
if (icon_text)
192+
free (icon_text);
190193
}
191194

192195
static int

0 commit comments

Comments
 (0)