[vlc-commits] sdp: use memcpy() instead of bespoke function

Rémi Denis-Courmont git at videolan.org
Wed Apr 22 21:29:31 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr 22 22:14:08 2020 +0300| [4c016d09e1f86959f5752ee06f03357acf9f1fab] | committer: Rémi Denis-Courmont

sdp: use memcpy() instead of bespoke function

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4c016d09e1f86959f5752ee06f03357acf9f1fab
---

 modules/access/sdp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/access/sdp.c b/modules/access/sdp.c
index c60eb9b29a..556c4fcb0f 100644
--- a/modules/access/sdp.c
+++ b/modules/access/sdp.c
@@ -32,14 +32,14 @@
 static ssize_t Read (stream_t *access, void *buf, size_t len)
 {
     const char **inp = access->p_sys, *in = *inp;
-    unsigned char *out = buf;
-    size_t i;
+    size_t avail = strnlen(in, len);
 
-    for (i = 0; i < len && *in != '\0'; i++)
-        *(out++) = *(in++);
+    if (len > avail)
+        len = avail;
 
-    *inp = in;
-    return i;
+    memcpy(buf, in, len);
+    *inp += len;
+    return len;
 }
 
 static int Seek (stream_t *access, uint64_t position)



More information about the vlc-commits mailing list