[vlc-commits] vlc_stream_ReadLine: fix trimming

Rémi Denis-Courmont git at videolan.org
Wed May 24 21:08:16 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 24 22:07:05 2017 +0300| [32ff0bbcada5e6d5c0e92e684b454764241fafa0] | committer: Rémi Denis-Courmont

vlc_stream_ReadLine: fix trimming

Removal of CR or LF final characters relied on the off-by-one bug fixed
in the previous changest, and no longer works. This adjusts it
accordingly.

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

 src/input/stream.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/input/stream.c b/src/input/stream.c
index a1eb20ec9e..1191e99b3d 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -332,8 +332,9 @@ char *vlc_stream_ReadLine( stream_t *s )
         }
 
         /* Remove trailing LF/CR */
-        while( i_line >= 2 && ( p_line[i_line-2] == '\r' ||
-            p_line[i_line-2] == '\n') ) i_line--;
+        while( i_line >= 1 &&
+               (p_line[i_line - 1] == '\r' || p_line[i_line - 1] == '\n') )
+            i_line--;
 
         /* Make sure the \0 is there */
         p_line[i_line] = '\0';



More information about the vlc-commits mailing list