summaryrefslogtreecommitdiff
path: root/glib/gbase64.c
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2019-02-27 10:13:18 +0000
committerPhilip Withnall <withnall@endlessm.com>2019-02-27 10:13:18 +0000
commit86e099c1342c90d308037d1a72515697e85f1106 (patch)
treeb7eb01416b5415281e30879a2420f8f995f31e61 /glib/gbase64.c
parent5c97cf666d85780e884a4b1363054af924e49ca2 (diff)
downloadglib-86e099c1342c90d308037d1a72515697e85f1106.tar.gz
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>
Diffstat (limited to 'glib/gbase64.c')
-rw-r--r--glib/gbase64.c4
1 files changed, 1 insertions, 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);