[libbluray-devel] Fix leak (error path)

Petri Hintukainen git at videolan.org
Sun Jun 18 20:26:39 CEST 2017


libudfread | branch: master | Petri Hintukainen <phintuka at gmail.com> | Sun Jun 18 20:56:34 2017 +0300| [04a620c03a4f3161a1133dd9ce7180dbff0b40ef] | committer: Petri Hintukainen

Fix leak (error path)

> http://git.videolan.org/gitweb.cgi/libudfread.git/?a=commit;h=04a620c03a4f3161a1133dd9ce7180dbff0b40ef
---

 src/udfread.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/udfread.c b/src/udfread.c
index 4b49170..d3cde6c 100644
--- a/src/udfread.c
+++ b/src/udfread.c
@@ -176,17 +176,19 @@ static char *_cs0_to_utf8(const uint8_t *cs0, size_t size)
     size_t   out_pos = 0;
     size_t   out_size = size;
     size_t   i;
-    uint8_t *out = (uint8_t *)malloc(size);
+    uint8_t *out;
 
-    if (!out) {
-        udf_error("out of memory\n");
-        return NULL;
-    }
     if (size < 1) {
         udf_error("too short cs0 string\n");
         return NULL;
     }
 
+    out = (uint8_t *)malloc(size);
+    if (!out) {
+        udf_error("out of memory\n");
+        return NULL;
+    }
+
     switch (cs0[0]) {
     case 8:
         /*udf_trace("string in utf-8\n");*/



More information about the libbluray-devel mailing list