[glib] GChecksum: accept NULL pointer with length 0



commit fb94e65a640d21b2e1a5c6e79eb3d755ba34c0e6
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jun 24 00:35:10 2010 -0400

    GChecksum: accept NULL pointer with length 0
    
    Several GChecksum functions were incorrectly aborting when passed a NULL
    data pointer, even if the length parameter was equal to zero.

 glib/gchecksum.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/glib/gchecksum.c b/glib/gchecksum.c
index ad90727..4b9ff94 100644
--- a/glib/gchecksum.c
+++ b/glib/gchecksum.c
@@ -1240,7 +1240,7 @@ g_checksum_update (GChecksum    *checksum,
                    gssize        length)
 {
   g_return_if_fail (checksum != NULL);
-  g_return_if_fail (data != NULL);
+  g_return_if_fail (length == 0 || data != NULL);
 
   if (length < 0)
     length = strlen ((const gchar *) data);
@@ -1415,7 +1415,7 @@ g_compute_checksum_for_data (GChecksumType  checksum_type,
   gchar *retval;
 
   g_return_val_if_fail (IS_VALID_TYPE (checksum_type), NULL);
-  g_return_val_if_fail (data != NULL, NULL);
+  g_return_val_if_fail (length == 0 || data != NULL, NULL);
 
   checksum = g_checksum_new (checksum_type);
   if (!checksum)
@@ -1449,7 +1449,7 @@ g_compute_checksum_for_string (GChecksumType  checksum_type,
                                gssize         length)
 {
   g_return_val_if_fail (IS_VALID_TYPE (checksum_type), NULL);
-  g_return_val_if_fail (str != NULL, NULL);
+  g_return_val_if_fail (length == 0 || str != NULL, NULL);
 
   if (length < 0)
     length = strlen (str);



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