From a102c62fac6c3df8fe81c88b93ce4dbb4002a991 Mon Sep 17 00:00:00 2001 From: arpi Date: Tue, 14 Jan 2003 23:15:36 +0000 Subject: sanity checks - patch by Fabian Franz cache results of strchr() calls git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8956 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/tv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libmpdemux/tv.c b/libmpdemux/tv.c index 3bff4b4e19..166cc1adb7 100644 --- a/libmpdemux/tv.c +++ b/libmpdemux/tv.c @@ -245,15 +245,18 @@ static int open_tv(tvi_handle_t *tvh) while (*tv_param_channels) { char* tmp = *(tv_param_channels++); + char* sep = strchr(tmp,'-'); int i; struct CHANLIST cl; - strcpy(tv_channel_current->name, strchr(tmp, '-') + 1); - strchr(tmp, '-')[0] = '\0'; + if (!sep) continue; // Wrong syntax, but mplayer should not crash + + strcpy(tv_channel_current->name, sep + 1); + sep[0] = '\0'; strncpy(tv_channel_current->number, tmp, 5); - while (strchr(tv_channel_current->name, '_')) - strchr(tv_channel_current->name, '_')[0] = ' '; + while ((sep=strchr(tv_channel_current->name, '_'))) + sep[0] = ' '; tv_channel_current->freq = 0; for (i = 0; i < chanlists[tvh->chanlist].count; i++) { @@ -277,8 +280,8 @@ static int open_tv(tvi_handle_t *tvh) tv_channel_current->next->next = NULL; tv_channel_current = tv_channel_current->next; } - - tv_channel_current->prev->next = NULL; + if (tv_channel_current->prev) + tv_channel_current->prev->next = NULL; free(tv_channel_current); } else tv_channel_last_real = malloc(sizeof(char)*5); -- cgit v1.2.3