Bug 12026

Summary: missing unlocks in src/* (font related)
Product: cairo Reporter: Roland "Test-tools" Bär <roland>
Component: generalAssignee: Carl Worth <cworth>
Status: RESOLVED MOVED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: medium CC: chris
Version: 1.5.1Keywords: patch
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: For src/cairo-ft-font.c
For src/cairo-ft-font.c
For src/cairo-type1-subset.c

Description Roland "Test-tools" Bär 2007-08-16 02:50:02 UTC
Found that missing unlocks, triggered by errors.

3 patches attached.
Comment 1 Roland "Test-tools" Bär 2007-08-16 02:54:02 UTC
Created attachment 11151 [details] [review]
For src/cairo-ft-font.c
Comment 2 Roland "Test-tools" Bär 2007-08-16 02:55:20 UTC
Created attachment 11152 [details] [review]
For src/cairo-ft-font.c
Comment 3 Roland "Test-tools" Bär 2007-08-16 02:58:59 UTC
Created attachment 11153 [details] [review]
For src/cairo-type1-subset.c
Comment 4 Chris Wilson 2007-08-16 03:27:20 UTC
Calling _cairo_ft_unscaled_font_unlock_face() after an error encountered during _cairo_ft_unscaled_font_lock_face() is wrong as the error path within lock_face() has already released the unscaled->mutex. Error paths are supposed to perform all necessary cleanup, but reading lock_face() it appears to be falsely incrementing unscaled->lock_count after an error. (And it looks like font_map->num_open_faces++ should be using an atomic op instead.)

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 4dc61ee..04441d0 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -552,6 +552,7 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t 
                     unscaled->id,
                     &face) != FT_Err_Ok)
     {
+       unscaled->lock_count--;
        CAIRO_MUTEX_UNLOCK (unscaled->mutex);
        _cairo_error (CAIRO_STATUS_NO_MEMORY);
        return NULL;
Comment 5 GitLab Migration User 2018-08-25 13:38:18 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/112.

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.