diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-01-14 23:15:36 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-01-14 23:15:36 +0000 |
commit | a102c62fac6c3df8fe81c88b93ce4dbb4002a991 (patch) | |
tree | 3d9c1b9374128243429f85596015b3ee779dfd73 | |
parent | 62dab30a971cad8ac9910a506aed76561236f392 (diff) | |
download | mpv-a102c62fac6c3df8fe81c88b93ce4dbb4002a991.tar.bz2 mpv-a102c62fac6c3df8fe81c88b93ce4dbb4002a991.tar.xz |
sanity checks - patch by Fabian Franz <FabianFranz@gmx.de>
cache results of strchr() calls
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8956 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libmpdemux/tv.c | 15 |
1 files 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); |