[glib] base64: remove unnecessary assertions
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] base64: remove unnecessary assertions
- Date: Thu, 8 Jul 2010 02:18:36 +0000 (UTC)
commit a00fa340cb776976b14fd1b9476d1488a75d8377
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Jul 7 22:00:43 2010 -0400
base64: remove unnecessary assertions
Allow base64 encoding/decoding of empty strings.
glib/gbase64.c | 5 +----
1 files changed, 1 insertions(+), 4 deletions(-)
---
diff --git a/glib/gbase64.c b/glib/gbase64.c
index bc2fa87..52982ce 100644
--- a/glib/gbase64.c
+++ b/glib/gbase64.c
@@ -254,8 +254,7 @@ g_base64_encode (const guchar *data,
gint state = 0, outlen;
gint save = 0;
- g_return_val_if_fail (data != NULL, NULL);
- g_return_val_if_fail (len > 0, NULL);
+ g_return_val_if_fail (data != NULL || len == 0, NULL);
/* We can use a smaller limit here, since we know the saved state is 0,
+1 is needed for trailing \0, also check for unlikely integer overflow */
@@ -398,8 +397,6 @@ g_base64_decode (const gchar *text,
input_length = strlen (text);
- g_return_val_if_fail (input_length > 1, NULL);
-
/* We can use a smaller limit here, since we know the saved state is 0,
+1 used to avoid calling g_malloc0(0), and hence retruning NULL */
ret = g_malloc0 ((input_length / 4) * 3 + 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]