GNOME Bugzilla – Bug 735337
Crash in inspector, in the CSS editor
Last modified: 2014-08-25 12:26:55 UTC
When using the inspector, I got a crash: > Gtk-ERROR **: Byte index 2 is off the end of the line See the attached patch to fix the problem. It happens with the following steps: Write custom CSS like: .left { background-color: white; } Try to comment the background-color: write /* just before the 'b'. In the following backtrace, show_parsing_error() is called (frame 7) and calls gtk_text_buffer_get_iter_at_line_index() with an invalid byte index (line 9 is the last line, which contains only the character '}', but byte_index is 2).
+ Trace 233996
Created attachment 284356 [details] [review] inspector: fix a crash in the CSS editor gtk_css_section_get_end_position() can return a position one byte beyond the end of the last line. gtk_text_buffer_get_iter_at_line_index() accepts only valid line_number/byte_index pairs. Another solution is to make the GtkTextBuffer function less strict, by returning a boolean if the exact position was found. The CSS parser should also be fixed to always return valid positions. But it's better to have a safety net in the CSS editor, just in case (a warning could be print).
See bug #735341 to fix the problem in GtkTextBuffer.
Review of attachment 284356 [details] [review]: I guess that is an ok short-term fix, until we have safer text iter apis