[vlc-devel] [PATCH 1/2] strings: vlc_xml_encode: check return of vlc_memstream_open

Filip Roséen filip at atch.se
Fri Feb 24 21:32:56 CET 2017


As the function is not guaranteed to succeed we should check the return-value
in order to prevent potentially using a handle which is not valid.
---
 src/text/strings.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/text/strings.c b/src/text/strings.c
index 45d72a1139..6daad07c68 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -289,7 +289,9 @@ char *vlc_xml_encode (const char *str)
     uint32_t cp;
 
     assert(str != NULL);
-    vlc_memstream_open(&stream);
+
+    if (vlc_memstream_open(&stream))
+        return NULL;
 
     while ((n = vlc_towc (str, &cp)) != 0)
     {
-- 
2.11.1



More information about the vlc-devel mailing list