mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-30 12:23:06 +02:00
gio: converter: Forbid null out arguments
Currently, inbuf_size and outbuf_size are not documented as not nullable, but they are expected to be so, which might lead to unexpected crashes. Moreover, outbuf itself is also expected to not be null, so this commit adds the appropriate GI annotations and early returns on failed preconditions.
This commit is contained in:
parent
f499e37979
commit
e0976efee9
@ -57,12 +57,14 @@ g_converter_default_init (GConverterInterface *iface)
|
||||
* @inbuf: (array length=inbuf_size) (element-type guint8): the buffer
|
||||
* containing the data to convert.
|
||||
* @inbuf_size: the number of bytes in @inbuf
|
||||
* @outbuf: (element-type guint8) (array length=outbuf_size): a buffer to write
|
||||
* converted data in.
|
||||
* @outbuf: (element-type guint8) (array length=outbuf_size) (not nullable): a
|
||||
* buffer to write converted data in.
|
||||
* @outbuf_size: the number of bytes in @outbuf, must be at least one
|
||||
* @flags: a #GConverterFlags controlling the conversion details
|
||||
* @bytes_read: (out): will be set to the number of bytes read from @inbuf on success
|
||||
* @bytes_written: (out): will be set to the number of bytes written to @outbuf on success
|
||||
* @bytes_read: (out) (not nullable): will be set to the number of bytes read
|
||||
* from @inbuf on success
|
||||
* @bytes_written: (out) (not nullable): will be set to the number of bytes
|
||||
* written to @outbuf on success
|
||||
* @error: location to store the error occurring, or %NULL to ignore
|
||||
*
|
||||
* This is the main operation used when converting data. It is to be called
|
||||
@ -166,7 +168,12 @@ g_converter_convert (GConverter *converter,
|
||||
GConverterIface *iface;
|
||||
|
||||
g_return_val_if_fail (G_IS_CONVERTER (converter), G_CONVERTER_ERROR);
|
||||
g_return_val_if_fail (inbuf != NULL || inbuf_size == 0, G_CONVERTER_ERROR);
|
||||
g_return_val_if_fail (outbuf != NULL, G_CONVERTER_ERROR);
|
||||
g_return_val_if_fail (outbuf_size > 0, G_CONVERTER_ERROR);
|
||||
g_return_val_if_fail (bytes_read != NULL, G_CONVERTER_ERROR);
|
||||
g_return_val_if_fail (bytes_written != NULL, G_CONVERTER_ERROR);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, G_CONVERTER_ERROR);
|
||||
|
||||
*bytes_read = 0;
|
||||
*bytes_written = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user