Updating branch refs/heads/master to a562cabe0cabec9ea478db8ad9c3579afe2146fc (commit) from d2f05a30067b53c3155e1af6efd25a12f4ae1dc5 (commit)
commit a562cabe0cabec9ea478db8ad9c3579afe2146fc Author: Landry Breuil <lan...@xfce.org> Date: Sat Oct 16 12:14:55 2010 +0200 Try to be more robust to rogue data in parse_playlistinfo_answer()/parse_outputs_answer() while looping on the parsing of an output or a song, check if we get an ok (which should not happen in normal case). If so, gracefully exit the parsing. only increment song/output counter if the parsing was ok. panel-plugin/simple-libmpd.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/panel-plugin/simple-libmpd.c b/panel-plugin/simple-libmpd.c index d035957..63e1689 100644 --- a/panel-plugin/simple-libmpd.c +++ b/panel-plugin/simple-libmpd.c @@ -414,7 +414,7 @@ void parse_playlistinfo_answer(MpdObj *mo, void *param) ms->id = ms->pos = -1; DBG("Going to parse song #%d", md->nb); - while(lines[i] && ms->id < 0) + while(lines[i] && strcmp(lines[i],"OK") && ms->id < 0) { tokens = g_strsplit(lines[i], ":", 2); /* remove leading whitespace */ @@ -430,7 +430,8 @@ void parse_playlistinfo_answer(MpdObj *mo, void *param) i++; g_strfreev(tokens); } - md->nb++; + if (lines[i] && strcmp(lines[i],"OK")) + md->nb++; } g_strfreev(lines); DBG("Got 'OK', md->nb = %d", md->nb); @@ -447,7 +448,7 @@ void parse_outputs_answer(MpdObj *mo, void *param) md->alloutputs[md->nb] = g_new(mpd_Output, 1); md->alloutputs[md->nb]->enabled = -1; DBG("Going to parse output #%d", md->nb); - while(lines[i] && md->alloutputs[md->nb]->enabled < 0) + while(lines[i] && strcmp(lines[i],"OK") && md->alloutputs[md->nb]->enabled < 0) { tokens = g_strsplit(lines[i], ":", 2); /* remove leading whitespace */ @@ -459,7 +460,8 @@ void parse_outputs_answer(MpdObj *mo, void *param) i++; g_strfreev(tokens); } - md->nb++; + if (lines[i] && strcmp(lines[i],"OK")) + md->nb++; } g_strfreev(lines); } _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits