[gimp] libgimpconfig: allow calling gimp_scanner_new_string (NULL, -1, ...)



commit dcea2348c6c79b581ddced1a59dba1ef654d5202
Author: Ell <ell_se yahoo com>
Date:   Wed Jan 29 21:08:35 2020 +0200

    libgimpconfig: allow calling gimp_scanner_new_string (NULL, -1, ...)
    
    Allow calling gimp_scanner_new_string() with a NULL `text` and a
    negative `text_len` (which is interpreted as 0), instead of
    requiring `text_len == 0` in this case.  This allows passing a
    negative `text_len` unconditionally to infer the length, even when
    the string may be NULL.

 libgimpconfig/gimpscanner.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/libgimpconfig/gimpscanner.c b/libgimpconfig/gimpscanner.c
index 63d3305187..888dd5b55a 100644
--- a/libgimpconfig/gimpscanner.c
+++ b/libgimpconfig/gimpscanner.c
@@ -243,11 +243,11 @@ gimp_scanner_new_string (const gchar  *text,
 {
   GimpScanner *scanner;
 
-  g_return_val_if_fail (text != NULL || text_len == 0, NULL);
+  g_return_val_if_fail (text != NULL || text_len <= 0, NULL);
   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
   if (text_len < 0)
-    text_len = strlen (text);
+    text_len = text ? strlen (text) : 0;
 
   scanner = gimp_scanner_new (NULL, NULL, NULL, error);
 


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