[vlc-commits] rar: call strchr() only once
Rémi Denis-Courmont
git at videolan.org
Sun Aug 23 09:16:07 CEST 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Aug 23 10:13:33 2015 +0300| [71690f13687241a8e68aea400967dac4ff1fafe8] | committer: Rémi Denis-Courmont
rar: call strchr() only once
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=71690f13687241a8e68aea400967dac4ff1fafe8
---
modules/access/rar/access.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/modules/access/rar/access.c b/modules/access/rar/access.c
index 3a8f11a..b6dec32 100644
--- a/modules/access/rar/access.c
+++ b/modules/access/rar/access.c
@@ -143,14 +143,15 @@ int RarAccessOpen(vlc_object_t *object)
{
access_t *access = (access_t*)object;
- if (!strchr(access->psz_location, '|'))
+ const char *name = strchr(access->psz_location, '|');
+ if (name == NULL)
return VLC_EGENERIC;
- char *base = strdup(access->psz_location);
- if (!base)
- return VLC_EGENERIC;
- char *name = strchr(base, '|');
- *name++ = '\0';
+ char *base = strndup(access->psz_location, name - access->psz_location);
+ if (unlikely(base == NULL))
+ return VLC_ENOMEM;
+
+ name++;
decode_URI(base);
stream_t *s = stream_UrlNew(access, base);
More information about the vlc-commits
mailing list