mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-03 01:36:17 +01:00
Fix several recently-introduced bugs in g_output_stream_write_async()
g_output_stream_write_async() was not initializing the newly-added members of the WriteData structure, causing various problems. Also, g_input_stream_read_async() was now leaking its cancellable. Fix that as well. https://bugzilla.gnome.org/show_bug.cgi?id=674612
This commit is contained in:
parent
00285b7517
commit
fd3ec4df87
@ -931,6 +931,14 @@ typedef struct {
|
|||||||
gboolean need_idle;
|
gboolean need_idle;
|
||||||
} ReadData;
|
} ReadData;
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_read_data (ReadData *op)
|
||||||
|
{
|
||||||
|
if (op->cancellable)
|
||||||
|
g_object_unref (op->cancellable);
|
||||||
|
g_slice_free (ReadData, op);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
read_async_thread (GSimpleAsyncResult *res,
|
read_async_thread (GSimpleAsyncResult *res,
|
||||||
GObject *object,
|
GObject *object,
|
||||||
@ -1017,9 +1025,9 @@ g_input_stream_real_read_async (GInputStream *stream,
|
|||||||
GSimpleAsyncResult *res;
|
GSimpleAsyncResult *res;
|
||||||
ReadData *op;
|
ReadData *op;
|
||||||
|
|
||||||
op = g_new (ReadData, 1);
|
op = g_slice_new0 (ReadData);
|
||||||
res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_input_stream_real_read_async);
|
res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_input_stream_real_read_async);
|
||||||
g_simple_async_result_set_op_res_gpointer (res, op, g_free);
|
g_simple_async_result_set_op_res_gpointer (res, op, (GDestroyNotify) free_read_data);
|
||||||
op->buffer = buffer;
|
op->buffer = buffer;
|
||||||
op->count_requested = count;
|
op->count_requested = count;
|
||||||
op->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
op->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
||||||
|
@ -1272,6 +1272,14 @@ typedef struct {
|
|||||||
gboolean need_idle;
|
gboolean need_idle;
|
||||||
} WriteData;
|
} WriteData;
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_write_data (WriteData *op)
|
||||||
|
{
|
||||||
|
if (op->cancellable)
|
||||||
|
g_object_unref (op->cancellable);
|
||||||
|
g_slice_free (WriteData, op);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_async_thread (GSimpleAsyncResult *res,
|
write_async_thread (GSimpleAsyncResult *res,
|
||||||
GObject *object,
|
GObject *object,
|
||||||
@ -1355,11 +1363,14 @@ g_output_stream_real_write_async (GOutputStream *stream,
|
|||||||
GSimpleAsyncResult *res;
|
GSimpleAsyncResult *res;
|
||||||
WriteData *op;
|
WriteData *op;
|
||||||
|
|
||||||
op = g_new0 (WriteData, 1);
|
op = g_slice_new0 (WriteData);
|
||||||
res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_output_stream_real_write_async);
|
res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_output_stream_real_write_async);
|
||||||
g_simple_async_result_set_op_res_gpointer (res, op, g_free);
|
g_simple_async_result_set_op_res_gpointer (res, op, (GDestroyNotify) free_write_data);
|
||||||
op->buffer = buffer;
|
op->buffer = buffer;
|
||||||
op->count_requested = count;
|
op->count_requested = count;
|
||||||
|
op->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
|
||||||
|
op->io_priority = io_priority;
|
||||||
|
op->need_idle = TRUE;
|
||||||
|
|
||||||
if (G_IS_POLLABLE_OUTPUT_STREAM (stream) &&
|
if (G_IS_POLLABLE_OUTPUT_STREAM (stream) &&
|
||||||
g_pollable_output_stream_can_poll (G_POLLABLE_OUTPUT_STREAM (stream)))
|
g_pollable_output_stream_can_poll (G_POLLABLE_OUTPUT_STREAM (stream)))
|
||||||
|
Loading…
Reference in New Issue
Block a user