mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-21 16:38:54 +02:00
Don't refuse to encode a single byte. (Milan Crha)
2007-11-23 Matthias Clasen <mclasen@redhat.com> * glib/gbase64.c (g_base64_encode): Don't refuse to encode a single byte. (Milan Crha) * tests/base64-test.c: Test encoding short strings. svn path=/trunk/; revision=5919
This commit is contained in:
committed by
Matthias Clasen
parent
39ad6fbd02
commit
78c06eafe1
@@ -231,16 +231,14 @@ g_base64_encode (const guchar *data,
|
||||
gint save = 0;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
g_return_val_if_fail (len > 1, NULL);
|
||||
g_return_val_if_fail (len > 0, NULL);
|
||||
|
||||
/* We can use a smaller limit here, since we know the saved state is 0 */
|
||||
out = g_malloc (len * 4 / 3 + 4);
|
||||
outlen = g_base64_encode_step (data, len, FALSE, out, &state, &save);
|
||||
outlen += g_base64_encode_close (FALSE,
|
||||
out + outlen,
|
||||
&state,
|
||||
&save);
|
||||
outlen += g_base64_encode_close (FALSE, out + outlen, &state, &save);
|
||||
out[outlen] = '\0';
|
||||
|
||||
return (gchar *) out;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user