[cairo-commit] cairo/src cairo-font.c, 1.73, 1.74 cairo-pattern.c, 1.61, 1.62 cairo-surface.c, 1.97, 1.98 cairo.c, 1.130, 1.131

Carl Worth commit at pdx.freedesktop.org
Tue Aug 23 14:04:31 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv31249/src

Modified Files:
	cairo-font.c cairo-pattern.c cairo-surface.c cairo.c 
Log Message:

2005-08-23  Carl Worth  <cworth at cworth.org>

        Reviewed by: otaylor
        Fixes bug #4198

        * src/cairo-font.c: (cairo_font_face_reference),
        (cairo_font_face_destroy), (cairo_scaled_font_reference),
        (cairo_scaled_font_destroy):
        * src/cairo-pattern.c: (cairo_pattern_reference),
        (cairo_pattern_destroy):
        * src/cairo-surface.c: (cairo_surface_reference),
        (cairo_surface_destroy):
        * src/cairo.c: (cairo_reference), (cairo_destroy):
        Detect (by assert and crash) if users attempt to twice destroy or
        re-reference a destroyed object. The condition for detecting this
        case is a ref_count of 0.


Index: cairo-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-font.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- cairo-font.c	23 Aug 2005 03:43:23 -0000	1.73
+++ cairo-font.c	23 Aug 2005 21:04:28 -0000	1.74
@@ -85,6 +85,8 @@
     if (font_face->ref_count == (unsigned int)-1)
 	return font_face;
 
+    assert (font_face->ref_count > 0);
+
     font_face->ref_count++;
 
     return font_face;
@@ -107,6 +109,8 @@
     if (font_face->ref_count == (unsigned int)-1)
 	return;
 
+    assert (font_face->ref_count > 0);
+
     if (--(font_face->ref_count) > 0)
 	return;
 
@@ -760,6 +764,8 @@
     if (scaled_font->ref_count == (unsigned int)-1)
 	return scaled_font;
 
+    assert (scaled_font->ref_count > 0);
+
     /* If the original reference count is 0, then this font must have
      * been found in font_map->holdovers, (which means this caching is
      * actually working). So now we remove it from the holdovers
@@ -807,6 +813,8 @@
     if (scaled_font->ref_count == (unsigned int)-1)
 	return;
 
+    assert (scaled_font->ref_count > 0);
+
     if (--(scaled_font->ref_count) > 0)
 	return;
 

Index: cairo-pattern.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-pattern.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- cairo-pattern.c	23 Aug 2005 03:43:23 -0000	1.61
+++ cairo-pattern.c	23 Aug 2005 21:04:28 -0000	1.62
@@ -532,6 +532,8 @@
     if (pattern->ref_count == (unsigned int)-1)
 	return pattern;
 
+    assert (pattern->ref_count > 0);
+
     pattern->ref_count++;
 
     return pattern;
@@ -570,6 +572,8 @@
     if (pattern->ref_count == (unsigned int)-1)
 	return;
 
+    assert (pattern->ref_count > 0);
+
     pattern->ref_count--;
     if (pattern->ref_count)
 	return;

Index: cairo-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-surface.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- cairo-surface.c	21 Aug 2005 19:13:17 -0000	1.97
+++ cairo-surface.c	23 Aug 2005 21:04:28 -0000	1.98
@@ -268,6 +268,8 @@
     if (surface->ref_count == (unsigned int)-1)
 	return surface;
 
+    assert (surface->ref_count > 0);
+
     surface->ref_count++;
 
     return surface;
@@ -290,6 +292,8 @@
     if (surface->ref_count == (unsigned int)-1)
 	return;
 
+    assert (surface->ref_count > 0);
+
     surface->ref_count--;
     if (surface->ref_count)
 	return;

Index: cairo.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.c,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- cairo.c	23 Aug 2005 07:03:10 -0000	1.130
+++ cairo.c	23 Aug 2005 21:04:28 -0000	1.131
@@ -222,6 +222,8 @@
 {
     if (cr->ref_count == (unsigned int)-1)
 	return cr;
+
+    assert (cr->ref_count > 0);
     
     cr->ref_count++;
 
@@ -241,6 +243,8 @@
 {
     if (cr->ref_count == (unsigned int)-1)
 	return;
+
+    assert (cr->ref_count > 0);
     
     cr->ref_count--;
     if (cr->ref_count)



More information about the cairo-commit mailing list