# HG changeset patch # User Matti Hamalainen # Date 1222054840 -10800 # Node ID 30d30cfe6b470fae8f1eef098da7a7ef11e965c6 # Parent 3877a02782bbea2dec4f11229685bae6289ecd5f Handle file == NULL in ungetc(). diff -r 3877a02782bb -r 30d30cfe6b47 src/stdio/stdio.c --- a/src/stdio/stdio.c Mon Sep 22 06:39:32 2008 +0300 +++ b/src/stdio/stdio.c Mon Sep 22 06:40:40 2008 +0300 @@ -77,7 +77,7 @@ gchar *decpath; if (!path || !mode) - return NULL; + return NULL; decpath = aud_vfs_stdio_urldecode_path(path); @@ -85,8 +85,7 @@ file->handle = fopen(decpath != NULL ? decpath : path, mode); - if (decpath != NULL) - g_free(decpath); + g_free(decpath); if (file->handle == NULL) { g_free(file); @@ -157,11 +156,16 @@ } gint -stdio_aud_vfs_ungetc_impl(gint c, VFSFile *stream) +stdio_aud_vfs_ungetc_impl(gint c, VFSFile * file) { - FILE *handle = (FILE *) stream->handle; - - return ungetc( c , handle ); + FILE *handle; + + if (file == NULL) + return -1; + + handle = (FILE *) file->handle; + + return ungetc(c, handle); } gint @@ -242,7 +246,7 @@ handle = (FILE *) file->handle; - if (-1 == fstat(fileno(handle), &s)) + if (fstat(fileno(handle), &s) == -1) return -1; return s.st_size;