Bug 136840 - gtk_text_view_backspace() dereferences NULL and dies a horrible flaming death
Summary: gtk_text_view_backspace() dereferences NULL and dies a horrible flaming death
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gtk2
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Owen Taylor
QA Contact:
URL:
Whiteboard:
: 136743 137238 (view as bug list)
Depends On:
Blocks: 131589
TreeView+ depends on / blocked
 
Reported: 2004-10-22 16:41 UTC by Dan Williams
Modified: 2007-11-30 22:10 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-10-23 03:20:22 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Dan Williams 2004-10-22 16:41:30 UTC
gtktextview.c/gtk_text_view_backspace() around line 5167:

      attrs = _gtk_text_buffer_get_line_log_attrs (get_buffer
(text_view), &insert, NULL);
      offset = gtk_text_iter_get_line_offset (&insert);
      backspace_deletes_character =
attrs[offset].backspace_deletes_character;

Ok, so if attrs == NULL, then attempting to do attrs[offset] will of
course segfault.

So, we look at _gtk_text_buffer_get_line_log_attrs():
  gint line;
  GtkTextLogAttrCache *cache;
  gint i;
    
  g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
  g_return_val_if_fail (anywhere_in_line != NULL, NULL);
    
  /* special-case for empty last line in buffer */
  if (gtk_text_iter_is_end (anywhere_in_line) &&
      gtk_text_iter_get_line_offset (anywhere_in_line) == 0)
    {
      if (char_len)
        *char_len = 0;
      return NULL;
    }
    
Hmm, NULL seems to be a valid return value for this function, which
would cause gtk_text_view_backspace() to get an attrs==NULL.

Test was:
1) run gedit
2) hit Enter
3) Hit backspace

Comment 1 Dan Williams 2004-10-22 17:10:22 UTC
*** Bug 136743 has been marked as a duplicate of this bug. ***

Comment 2 Dan Williams 2004-10-22 19:12:45 UTC
Appears fixed with 2.4.13-3 in fc3-HEAD

Comment 3 Warren Togami 2004-10-23 03:20:22 UTC
Indeed it seems good here too, and it was pushed to dist-fc3.  Closing.


Comment 4 Dan Williams 2004-10-26 21:14:52 UTC
*** Bug 137238 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.