[gegl] gegl: Use of memory after it is freed in gegl_color_get_components.



commit a4afb4b99dd9d1e9250d3da8ff2d6bf9743a9aa7
Author: Axel Viala <axel viala darnuria eu>
Date:   Thu Mar 31 16:22:58 2022 +0200

    gegl: Use of memory after it is freed in gegl_color_get_components.
    
    Found with scan-build using:
    ```
    clang version 13.0.1
    Target: x86_64-pc-linux-gnu
    Thread model: posix
    InstalledDir: /usr/sbin
    ```
    
    ```
    [88/1269] Compiling C object gegl/libgegl-0.4.so.0.436.1.p/gegl-introspection-support.c.o
    ../../../gegl/gegl-introspection-support.c:142:7: warning: Use of memory after it is freed [unix.Malloc]
          return result;
          ^~~~~~~~~~~~~
    ```

 gegl/gegl-introspection-support.c | 1 +
 gegl/gegl-introspection-support.h | 1 +
 2 files changed, 2 insertions(+)
---
diff --git a/gegl/gegl-introspection-support.c b/gegl/gegl-introspection-support.c
index 7ade818fc..16b272f37 100644
--- a/gegl/gegl-introspection-support.c
+++ b/gegl/gegl-introspection-support.c
@@ -136,6 +136,7 @@ gegl_color_get_components (GeglColor *color,
       else
         {
           g_free (result);
+          result = NULL;
           *components_length = 0;
         }
 
diff --git a/gegl/gegl-introspection-support.h b/gegl/gegl-introspection-support.h
index e9412717d..d4357c330 100644
--- a/gegl/gegl-introspection-support.h
+++ b/gegl/gegl-introspection-support.h
@@ -61,6 +61,7 @@ gegl_format_get_name (GValue *format);
  * Get the component values of the color in @format.
  *
  * Return value: (transfer full) (array length=components_length): The color components
+ * If value format not supported return NULL and components_length set to 0.
  */
 gdouble *
 gegl_color_get_components (GeglColor *color, GValue *format, gint *components_length);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]