Bug 21062 - SIGSEGV when mmap() fails
Summary: SIGSEGV when mmap() fails
Status: RESOLVED FIXED
Alias: None
Product: fontconfig
Classification: Unclassified
Component: library (show other bugs)
Version: 2.6
Hardware: All Linux (All)
: medium normal
Assignee: Keith Packard
QA Contact: Behdad Esfahbod
URL:
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2009-04-05 09:57 UTC by Serge van den Boom
Modified: 2009-06-24 12:36 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Fix (343 bytes, patch)
2009-04-05 09:57 UTC, Serge van den Boom
Details | Splinter Review

Description Serge van den Boom 2009-04-05 09:57:32 UTC
Created attachment 24582 [details] [review]
Fix

In fccache.c, there is the line
    cache = mmap (0, fd_stat->st_size, PROT_READ, MAP_SHARED, fd, 0);
Furtheron there is the check
    if (!cache)
But mmap() returns MAP_FAILED on failure, which is (void *) -1, and not NULL. So if mmap() fails, the guard of that if-statement will evaluate to false, and no cache is allocated, resulting in a crash a few lines later at
    if (cache->magic != FC_CACHE_MAGIC_MMAP
Comment 1 Behdad Esfahbod 2009-04-05 16:00:53 UTC
Oops.  Thanks for the patch.  In my tree now.
Comment 2 Behdad Esfahbod 2009-06-24 12:36:02 UTC
I believe I've fixed this in 2.7.0.  Please reopen otherwise.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.