[glib: 1/6] gbase64: Convert a precondition from g_error() to g_return_val_if_fail()
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/6] gbase64: Convert a precondition from g_error() to g_return_val_if_fail()
- Date: Wed, 27 Feb 2019 11:42:24 +0000 (UTC)
commit 86e099c1342c90d308037d1a72515697e85f1106
Author: Philip Withnall <withnall endlessm com>
Date: Wed Feb 27 10:13:18 2019 +0000
gbase64: Convert a precondition from g_error() to g_return_val_if_fail()
The caller needs to check this themselves in any case, so we might as
well at least follow convention in defining the precondition.
Signed-off-by: Philip Withnall <withnall endlessm com>
glib/gbase64.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
---
diff --git a/glib/gbase64.c b/glib/gbase64.c
index ae9d5fef5..d3416e310 100644
--- a/glib/gbase64.c
+++ b/glib/gbase64.c
@@ -268,9 +268,7 @@ g_base64_encode (const guchar *data,
/* 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 */
- if (len >= ((G_MAXSIZE - 1) / 4 - 1) * 3)
- g_error("%s: input too large for Base64 encoding (%"G_GSIZE_FORMAT" chars)",
- G_STRLOC, len);
+ g_return_val_if_fail (len < ((G_MAXSIZE - 1) / 4 - 1) * 3, NULL);
out = g_malloc ((len / 3 + 1) * 4 + 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]