GNOME Bugzilla – Bug 776323
Various warning and Coverity fixes
Last modified: 2017-01-29 07:46:26 UTC
Fixes from running Coverity on libgxps. These should all be explained in the commit messages, but please let me know if anything is unclear.
Created attachment 342280 [details] [review] lib: Fix uninitialised variables These could have been used later in the code if the relevant keys were not present in the XPS file to set their values. Coverity IDs: 1391239, 1391240
Created attachment 342281 [details] [review] lib: Prevent created property being set when content-type is set There was a missing break statement. Coverity ID: 1391236
Created attachment 342282 [details] [review] lib: Document explicit fall-through case in glyph parser Make it clear that this is not an accidentally missing break statement. Coverity ID: 1391237
Created attachment 342283 [details] [review] lib: Remove redundant NULL check utf8 is dereferenced earlier in the function, so if it’s NULL then we will have already crashed. Rearrange the function to add an explicit non-NULL check. Coverity ID: 1391238
Created attachment 342284 [details] [review] lib: Ignore a warning about a deprecated libarchive function archive_read_finish() is deprecated in favour of archive_read_free() in libarchive version 3.0; but was not deprecated in version 2.0, which we need to continue to support. See http://manpages.org/archive_read_finish/3
Comment on attachment 342281 [details] [review] lib: Prevent created property being set when content-type is set Oops
Review of attachment 342283 [details] [review]: ::: libgxps/gxps-glyphs.c @@ +205,3 @@ + g_assert (utf8 != NULL); + + utf8_len = g_utf8_next_char (utf8) - utf8; This is also useless if *utf8 == '\0'. I think we could leave the current early return and simply use g_utf8_next_char (utf8) - utf8 in the cairo_scaled_font_text_to_glyphs call instead of the utf8_len variable.
Attachment 342280 [details] pushed as 86d1e66 - lib: Fix uninitialised variables Attachment 342281 [details] pushed as ae5f6a3 - lib: Prevent created property being set when content-type is set Attachment 342282 [details] pushed as 5444885 - lib: Document explicit fall-through case in glyph parser Attachment 342284 [details] pushed as b8d9bf2 - lib: Ignore a warning about a deprecated libarchive function
Created attachment 342390 [details] [review] lib: Fix potential NULL pointer dereference utf8 is dereferenced earlier in the function than the NULL check, so if it is NULL, this will crash. Move the length calculation lower down to avoid this. Coverity ID: 1391238
Comment on attachment 342390 [details] [review] lib: Fix potential NULL pointer dereference I had forgotten this, pushed now.