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



commit 0566ae3e0a1268035c38567e4fb157d5992bf25e
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 08c15ecaab..8f65d08d37 100644
--- a/libgimpconfig/gimpscanner.c
+++ b/libgimpconfig/gimpscanner.c
@@ -263,11 +263,11 @@ gimp_scanner_new_string (const gchar  *text,
 {
   GScanner *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]