Mercurial > pidgin.yaz
comparison pidgin/gtksourceundomanager.c @ 19548:e2135da444a5
"text" isn't guarranteed to be null terminated, so make sure we use
the given "length" parameter. Fixes #2224.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 30 Aug 2007 07:03:12 +0000 |
parents | a92cadf6a978 |
children | 44b4e8bd759b |
comparison
equal
deleted
inserted
replaced
19547:6c726af063c9 | 19548:e2135da444a5 |
---|---|
675 GtkSourceUndoAction undo_action; | 675 GtkSourceUndoAction undo_action; |
676 | 676 |
677 if (um->priv->running_not_undoable_actions > 0) | 677 if (um->priv->running_not_undoable_actions > 0) |
678 return; | 678 return; |
679 | 679 |
680 g_return_if_fail (strlen (text) >= (guint)length); | |
681 | |
682 undo_action.action_type = GTK_SOURCE_UNDO_ACTION_INSERT; | 680 undo_action.action_type = GTK_SOURCE_UNDO_ACTION_INSERT; |
683 | 681 |
684 undo_action.action.insert.pos = gtk_text_iter_get_offset (pos); | 682 undo_action.action.insert.pos = gtk_text_iter_get_offset (pos); |
685 undo_action.action.insert.text = (gchar*) text; | 683 undo_action.action.insert.text = (gchar*) text; |
686 undo_action.action.insert.length = length; | 684 undo_action.action.insert.length = length; |
772 { | 770 { |
773 action = g_new (GtkSourceUndoAction, 1); | 771 action = g_new (GtkSourceUndoAction, 1); |
774 *action = *undo_action; | 772 *action = *undo_action; |
775 | 773 |
776 if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT) | 774 if (action->action_type == GTK_SOURCE_UNDO_ACTION_INSERT) |
777 action->action.insert.text = g_strdup (undo_action->action.insert.text); | 775 action->action.insert.text = g_strndup (undo_action->action.insert.text, undo_action->action.insert.length); |
778 else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE) | 776 else if (action->action_type == GTK_SOURCE_UNDO_ACTION_DELETE) |
779 action->action.delete.text = g_strdup (undo_action->action.delete.text); | 777 action->action.delete.text = g_strdup (undo_action->action.delete.text); |
780 else | 778 else |
781 { | 779 { |
782 g_free (action); | 780 g_free (action); |