# HG changeset patch # User William Pitcock # Date 1241054491 18000 # Node ID e02b6092f70e6fd9839b2f54b852d5b8f3bfc00c # Parent 01d2f931aeeb46f806b2e9c8bfd6e718764c9ec0 gio: handle ungetc() stack accesses larger than size (e.g. support size * nmemb as it should be) diff -r 01d2f931aeeb -r e02b6092f70e src/gio/gio.c --- a/src/gio/gio.c Wed Apr 29 20:09:59 2009 -0500 +++ b/src/gio/gio.c Wed Apr 29 20:21:31 2009 -0500 @@ -109,6 +109,7 @@ { VFSGIOHandle *handle; goffset count = 0; + gsize realsize = (size * nmemb); g_return_val_if_fail(file != NULL, EOF); g_return_val_if_fail(file->handle != NULL, EOF); @@ -119,7 +120,7 @@ if (handle->stream_stack != NULL) { guchar uc; - while ((count < size) && (handle->stream_stack != NULL)) + while ((count < realsize) && (handle->stream_stack != NULL)) { uc = GPOINTER_TO_INT(handle->stream_stack->data); handle->stream_stack = g_slist_delete_link(handle->stream_stack, handle->stream_stack); @@ -128,7 +129,7 @@ } } - return g_input_stream_read(G_INPUT_STREAM(handle->istream), (ptr + count), ((size * nmemb) - count), NULL, NULL); + return g_input_stream_read(G_INPUT_STREAM(handle->istream), (ptr + count), (realsize - count), NULL, NULL); } size_t