[glib: 1/3] gconvert: Add an assertion to help static analysis




commit b810bdc94dd81c0be4cad35a5cec3eec55a852b8
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu May 5 11:19:50 2022 +0100

    gconvert: Add an assertion to help static analysis
    
    `g_convert()` returns `NULL` iff it returns an error, but the static
    analyser can’t quite work that out. Add an assertion to help.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Coverity CID: #1486844

 glib/gconvert.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/glib/gconvert.c b/glib/gconvert.c
index bbc753ee6b..4ae0630d5d 100644
--- a/glib/gconvert.c
+++ b/glib/gconvert.c
@@ -681,6 +681,8 @@ g_convert_with_fallback (const gchar *str,
   if (!local_error)
     return dest;
 
+  g_assert (dest == NULL);
+
   if (!g_error_matches (local_error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
     {
       g_propagate_error (error, local_error);


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