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>
This commit is contained in:
Philip Withnall 2019-02-27 10:13:18 +00:00
parent 5c97cf666d
commit 86e099c134

View File

@ -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);