summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-03-19 12:27:43 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-03-19 12:27:43 +0000
commite2b86200e54ce8b7917f36bb09fa45dc5dbd66a8 (patch)
treece7256f0120ce6110d20c96f2f7db610f162861d
parentf05be99189d928c3ebfeb8c6b6fded34cdca6671 (diff)
parent4c02b0ad0a9d8f5fc3b09ae7ae45abf142f99d23 (diff)
downloadpango-e2b86200e54ce8b7917f36bb09fa45dc5dbd66a8.tar.gz
Merge branch 'memdup2' into 'master'
Memdup2 See merge request GNOME/pango!300
-rw-r--r--pango/glyphstring.c10
-rw-r--r--pango/pango-impl-utils.h8
-rw-r--r--pango/pango-layout.c4
-rw-r--r--pango/pangocoretext-fontmap.c2
-rw-r--r--pango/pangofc-fontmap.c4
-rw-r--r--pango/pangoft2-render.c5
6 files changed, 21 insertions, 12 deletions
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index 649e7758..6c2338f1 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -112,15 +112,15 @@ pango_glyph_string_copy (PangoGlyphString *string)
if (string == NULL)
return NULL;
-
+
new_string = g_slice_new (PangoGlyphString);
*new_string = *string;
- new_string->glyphs = g_memdup (string->glyphs,
- string->space * sizeof (PangoGlyphInfo));
- new_string->log_clusters = g_memdup (string->log_clusters,
- string->space * sizeof (gint));
+ new_string->glyphs = g_memdup2 (string->glyphs,
+ string->space * sizeof (PangoGlyphInfo));
+ new_string->log_clusters = g_memdup2 (string->log_clusters,
+ string->space * sizeof (gint));
return new_string;
}
diff --git a/pango/pango-impl-utils.h b/pango/pango-impl-utils.h
index 92a1168e..d2420321 100644
--- a/pango/pango-impl-utils.h
+++ b/pango/pango-impl-utils.h
@@ -201,6 +201,14 @@ pango_get_ignorable_size (gunichar ch,
return nick;
}
+/* Backward compatibility shim, to avoid bumping up the minimum
+ * required version of GLib; most of our uses of g_memdup() are
+ * safe, and those that aren't have been fixed
+ */
+#if !GLIB_CHECK_VERSION (2, 67, 3)
+# define g_memdup2(mem,size) g_memdup((mem),(size))
+#endif
+
G_END_DECLS
#endif /* __PANGO_IMPL_UTILS_H__ */
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 5298647e..1f86150e 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -6186,8 +6186,8 @@ pango_layout_iter_copy (PangoLayoutIter *iter)
new->line_extents = NULL;
if (iter->line_extents != NULL)
{
- new->line_extents = g_memdup (iter->line_extents,
- iter->layout->line_count * sizeof (Extents));
+ new->line_extents = g_memdup2 (iter->line_extents,
+ iter->layout->line_count * sizeof (Extents));
}
new->line_index = iter->line_index;
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 78003e6c..09437b4a 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -703,7 +703,7 @@ pango_core_text_family_list_faces (PangoFontFamily *family,
*n_faces = ctfamily->n_faces;
if (faces)
- *faces = g_memdup (ctfamily->faces, ctfamily->n_faces * sizeof (PangoFontFace *));
+ *faces = g_memdup2 (ctfamily->faces, ctfamily->n_faces * sizeof (PangoFontFace *));
}
static const char *
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 5d5dfe55..16f10747 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -1745,7 +1745,7 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap,
*n_families = priv->n_families;
if (families)
- *families = g_memdup (priv->families, priv->n_families * sizeof (PangoFontFamily *));
+ *families = g_memdup2 (priv->families, priv->n_families * sizeof (PangoFontFamily *));
}
static PangoFontFamily *
@@ -3262,7 +3262,7 @@ pango_fc_family_list_faces (PangoFontFamily *family,
*n_faces = fcfamily->n_faces;
if (faces)
- *faces = g_memdup (fcfamily->faces, fcfamily->n_faces * sizeof (PangoFontFace *));
+ *faces = g_memdup2 (fcfamily->faces, fcfamily->n_faces * sizeof (PangoFontFace *));
}
static PangoFontFace *
diff --git a/pango/pangoft2-render.c b/pango/pangoft2-render.c
index 45230fdb..45ac5820 100644
--- a/pango/pangoft2-render.c
+++ b/pango/pangoft2-render.c
@@ -25,6 +25,7 @@
#include "pango-font-private.h"
#include "pangoft2-private.h"
+#include "pango-impl-utils.h"
/* for compatibility with older freetype versions */
#ifndef FT_LOAD_TARGET_MONO
@@ -227,8 +228,8 @@ pango_ft2_font_render_glyph (PangoFont *font,
ft_render_mode_mono : ft_render_mode_normal));
rendered->bitmap = face->glyph->bitmap;
- rendered->bitmap.buffer = g_memdup (face->glyph->bitmap.buffer,
- face->glyph->bitmap.rows * face->glyph->bitmap.pitch);
+ rendered->bitmap.buffer = g_memdup2 (face->glyph->bitmap.buffer,
+ face->glyph->bitmap.rows * face->glyph->bitmap.pitch);
rendered->bitmap_left = face->glyph->bitmap_left;
rendered->bitmap_top = face->glyph->bitmap_top;