From 5fbfef4cb7ea7d512f9d8fff94cdeef116eb2af5 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 21 Jan 2008 13:11:13 +0000 Subject: [PATCH] Accept -1 for the data length if the data is a null-terminated string. Bug 2008-01-20 Murray Cumming * glib/gchecksum.c: (g_checksum_update): Accept -1 for the data length if the data is a null-terminated string. Bug #510855. svn path=/trunk/; revision=6340 --- ChangeLog | 5 +++++ glib/gchecksum.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75b8642..4524b2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-01-20 Murray Cumming + + * glib/gchecksum.c: (g_checksum_update): Accept -1 for the data + length if the data is a null-terminated string. Bug #510855. + 2008-01-21 Alexander Larsson * configure.in: diff --git a/glib/gchecksum.c b/glib/gchecksum.c index c7108ad..71ee2f7 100644 --- a/glib/gchecksum.c +++ b/glib/gchecksum.c @@ -1187,7 +1187,7 @@ g_checksum_free (GChecksum *checksum) * g_checksum_update: * @checksum: a #GChecksum * @data: buffer used to compute the checksum - * @length: size of the buffer + * @length: size of the buffer, or -1 if it is a null-terminated string. * * Feeds @data into an existing #GChecksum. The checksum must still be * open, that is g_checksum_get_string() or g_checksum_get_digest() must @@ -1203,6 +1203,9 @@ g_checksum_update (GChecksum *checksum, g_return_if_fail (checksum != NULL); g_return_if_fail (data != NULL); + if (length < 0) + length = strlen (data); + if (checksum->digest_str) { g_warning ("The checksum `%s' has been closed and cannot be updated " @@ -1387,7 +1390,7 @@ g_compute_checksum_for_data (GChecksumType checksum_type, * g_compute_checksum_for_string: * @checksum_type: a #GChecksumType * @str: the string to compute the checksum of - * @length: the length of the string, or -1 + * @length: the length of the string, or -1 if the string is null-terminated. * * Computes the checksum of a string. * -- 2.7.4