]> git.sesse.net Git - vlc/blobdiff - modules/stream_filter/httplive.c
hls: Fix parse_SegmentInformation error checking.
[vlc] / modules / stream_filter / httplive.c
index f9eba1207686aa95a982a3a03509b4ace13e18e6..7c72abda44a4ebc59cc91fa5e68d0230f4362ff6 100644 (file)
 #endif
 
 #include <limits.h>
-#include <errno.h>
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 
 #include <assert.h>
+#include <errno.h>
 #include <gcrypt.h>
 
 #include <vlc_threads.h>
@@ -577,8 +577,9 @@ static int parse_SegmentInformation(hls_stream_t *hls, char *p_read, int *durati
     char *endptr;
     if (hls->version < 3)
     {
+       errno = 0;
        value = strtol(token, &endptr, 10);
-       if (token == endptr)
+       if (token == endptr || errno == ERANGE )
        {
            *duration = -1;
            return VLC_EGENERIC;
@@ -587,8 +588,9 @@ static int parse_SegmentInformation(hls_stream_t *hls, char *p_read, int *durati
     }
     else
     {
+        errno = 0;
         double d = strtof(token, &endptr);
-        if (token == endptr)
+        if (token == endptr || errno == ERANGE )
         {
             *duration = -1;
             return VLC_EGENERIC;
@@ -597,6 +599,7 @@ static int parse_SegmentInformation(hls_stream_t *hls, char *p_read, int *durati
             value = ((int)d) + 1;
         else
             value = ((int)d);
+        *duration = value;
     }
 
     /* Ignore the rest of the line */