[nautilus] view-dnd: pass the correct attrs number to pango_get_log_attrs()



commit 16ea52970d059a1c03dc1ce27dc78f067421dc92
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Aug 16 18:30:57 2013 +0200

    view-dnd: pass the correct attrs number to pango_get_log_attrs()
    
    num_attrs always needs to be the number of characters plus one, or Pango
    will warn and possibly corrupt memory.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706131

 src/nautilus-view-dnd.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-view-dnd.c b/src/nautilus-view-dnd.c
index c50c465..5459f97 100644
--- a/src/nautilus-view-dnd.c
+++ b/src/nautilus-view-dnd.c
@@ -354,9 +354,9 @@ get_drop_filename (const char *text)
        PangoLogAttr *attrs;
        gchar *current_char;
 
-       num_attrs = MIN (g_utf8_strlen (text, -1) + 1, MAX_LEN_FILENAME);
+       num_attrs = MIN (g_utf8_strlen (text, -1), MAX_LEN_FILENAME) + 1;
        attrs = g_new (PangoLogAttr, num_attrs);
-       g_utf8_strncpy (trimmed, text, num_attrs);
+       g_utf8_strncpy (trimmed, text, num_attrs - 1);
        pango_get_log_attrs (trimmed, -1, -1, pango_language_get_default (), attrs, num_attrs);
 
        /* since the end of the text will always match a word boundary don't include it */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]