diff --git a/ChangeLog b/ChangeLog index 02030de8c..6a258bc28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ +2007-12-20 Matthias Clasen + + * glib/gchecksum.[hc] (g_checksum_new): Return NULL when + the checksum_type is unknown. (#501853) + 2007-12-20 Christian Persch - * glib/gchecksum.c: (g_checksum_new): Use g_slice_new0, to fix + * glib/gchecksum.c (g_checksum_new): Use g_slice_new0, to fix "conditional jump or move depends on uninitialised value(s)" error from valgrind. Bug #504527. diff --git a/glib/gchecksum.c b/glib/gchecksum.c index e6783de06..bda38b829 100644 --- a/glib/gchecksum.c +++ b/glib/gchecksum.c @@ -1052,9 +1052,9 @@ sha256_sum_digest (Sha256sum *sha256, * g_checksum_type_get_length: * @checksum_type: a #GChecksumType * - * Gets the length in bytes of digests of type @type + * Gets the length in bytes of digests of type @checksum_type * - * Return value: the checksum length, or -1 if @type is + * Return value: the checksum length, or -1 if @checksum_type is * not supported. * * Since: 2.16 @@ -1087,8 +1087,9 @@ g_checksum_type_get_length (GChecksumType checksum_type) * g_checksum_new: * @checksum_type: the desired type of checksum * - * Creates a new #GChecksum, using the checksum algorithm @type. A - * #GChecksum can be used to compute the checksum, or digest, of an + * Creates a new #GChecksum, using the checksum algorithm @checksum_type. + * If the @checksum_type is not known, %NULL is returned. + * A #GChecksum can be used to compute the checksum, or digest, of an * arbitrary binary blob, using different hashing algorithms. * * A #GChecksum works by feeding a binary blob through g_checksum_update() @@ -1100,8 +1101,8 @@ g_checksum_type_get_length (GChecksumType checksum_type) * will be closed and it won't be possible to call g_checksum_update() * on it anymore. * - * Return value: the newly created #GChecksum. Use g_checksum_free() to - * free the memory allocated by it. + * Return value: the newly created #GChecksum, or %NULL. + * Use g_checksum_free() to free the memory allocated by it. * * Since: 2.16 */ @@ -1110,7 +1111,8 @@ g_checksum_new (GChecksumType checksum_type) { GChecksum *checksum; - g_return_val_if_fail (IS_VALID_TYPE (checksum_type), NULL); + if (! IS_VALID_TYPE (checksum_type)) + return NULL; checksum = g_slice_new0 (GChecksum); checksum->type = checksum_type; diff --git a/glib/gchecksum.h b/glib/gchecksum.h index efa0e1b65..7450d7807 100644 --- a/glib/gchecksum.h +++ b/glib/gchecksum.h @@ -34,8 +34,8 @@ G_BEGIN_DECLS * The hashing algorithm to be used by #GChecksum when performing the * digest of some data. * - * The #GChecksumType enumeration can be extended at later date to include - * new hashing algorithm types. + * Note that the #GChecksumType enumeration may be extended at a later + * date to include new hashing algorithm types. * * Since: 2.16 */