Bug 92284 - crash when pasting HTML
Summary: crash when pasting HTML
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Laurence Withers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-28 22:04 UTC by Paulo Moura Guedes
Modified: 2004-10-30 00:52 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
The to copy the text. (10.20 KB, text/html)
2004-10-28 22:05 UTC, Paulo Moura Guedes
Details
The file to paste the text. (2.91 KB, text/html)
2004-10-28 22:08 UTC, Paulo Moura Guedes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paulo Moura Guedes 2004-10-28 22:04:32 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:                Linux

When I copy some specific text and paste over a selection of a specific document, kate (or kate part) crashes:

1. Select all in news.html
2. Copy
3. Select all in docs.html.
4. Paste
Kate crashes.
Comment 1 Paulo Moura Guedes 2004-10-28 22:05:33 UTC
Created attachment 8071 [details]
The to copy the text.
Comment 2 Paulo Moura Guedes 2004-10-28 22:08:09 UTC
Created attachment 8072 [details]
The file to paste the text.
Comment 3 Paulo Moura Guedes 2004-10-28 22:08:40 UTC
Some items I forgot:
1. My kdelibs are from HEAD and kdebase from KDE_3_3_BRANCH from 04/10/2004.
2. Backtrace:

Using host libthread_db library "/lib/tls/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -151023488 (LWP 3584)]
[KCrash handler]
#4  0x012b1cc2 in QString::operator= () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#5  0x012ae9b7 in QRegExp::prepareEngineForMatch ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#6  0x012adf8c in QRegExp::search () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#7  0x012adf53 in QRegExp::search () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#8  0x012b842d in QString::find () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#9  0x022d21ad in KateXmlIndent::processLine (this=0x837ef68, line=89)
    at kateautoindent.cpp:1218
#10 0x022d1ce7 in KateXmlIndent::processSection (this=0x837ef68, 
    begin=@0xfef06260, end=@0xfef06250) at kateautoindent.cpp:1098
#11 0x0226d979 in KateDocument::paste (this=0x820bda0, view=0x8408cf8)
    at katedocument.cpp:3297
#12 0x022af035 in KateViewInternal::doPaste (this=0x8495470)
    at kateviewinternal.cpp:941
#13 0x022ffd62 in KateView::paste (this=0x8408cf8) at kateview.h:84
#14 0x0228ec0e in KateView::qt_invoke (this=0x8408cf8, _id=106, _o=0xfef06390)
    at kateview.moc:586
#15 0x00fddffc in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#16 0x00fdde24 in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#17 0x00257f04 in KAction::activated (this=0x8408c78) at kaction.moc:157
#18 0x002578c1 in KAction::slotActivated (this=0x8408c78) at kaction.cpp:1073
#19 0x00268879 in KPasteTextAction::slotActivated (this=0x8408c78)
    at kactionclasses.cpp:2257
#20 0x0026b918 in KPasteTextAction::qt_invoke (this=0x8408c78, _id=17, 
    _o=0xfef06500) at kactionclasses.moc:1528
#21 0x00fddffc in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#22 0x00fdde24 in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#23 0x00b78158 in KAccelPrivate::menuItemActivated (this=0x84e9748)
    at kaccelprivate.moc:110
#24 0x00b7668d in KAccelPrivate::eventFilter (this=0x84e9748, 
    pEvent=0xfef06a10) at kaccel.cpp:350
#25 0x00fdb92e in QObject::activate_filters ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#26 0x00fdb85c in QObject::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#27 0x0101400f in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#28 0x010d2322 in QMainWindow::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#29 0x05f7ada4 in KMdiMainFrm::event (this=0x8328248, e=0xfef06a10)
    at kmdimainfrm.cpp:1070
#30 0x00f81aff in QApplication::internalNotify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#31 0x00f815f4 in QApplication::notify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#32 0x00b0c992 in KApplication::notify (this=0xfef06e90, receiver=0x8495470, 
    event=0xfef06a10) at kapplication.cpp:516
#33 0x009c1567 in QApplication::sendEvent (receiver=0x8495470, 
    event=0xfef06a10) at qapplication.h:491
#34 0x00b75373 in KAccelEventHandler::x11Event (this=0x83075e0, 
    pEvent=0xfef06dc0) at kaccel.cpp:141
#35 0x00c18517 in KAppX11HackWidget::publicx11Event (this=0x83075e0, 
    e=0xfef06dc0) at kapplication.cpp:1645
#36 0x00b11b0e in KApplication::x11EventFilter (this=0xfef06e90, 
    _event=0xfef06dc0) at kapplication.cpp:1713
#37 0x00f0b6d8 in qt_set_x11_event_filter ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#38 0x00f1536b in QApplication::x11ProcessEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#39 0x00f2c2b4 in QEventLoop::processEvents ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#40 0x00f93d48 in QEventLoop::enterLoop ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#41 0x00f93bf8 in QEventLoop::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#42 0x00f81d51 in QApplication::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#43 0x0093176f in kdemain (argc=1, argv=0x80d2450) at katemain.cpp:106
#44 0x008aa775 in kdeinitmain (argc=1, argv=0x80d2450) at kate_dummy.cpp:2
#45 0x0804e2a9 in launch (argc=1, _name=0x8198074 "kate", 
    args=0x8198079 "\001", cwd=0x0, envc=1, envs=0x819808a "", 
    reset_env=false, tty=0x0, avoid_loops=false, 
    startup_id_str=0x819808e "a83-132-25-69.netcabo.pt;1098993499;409424;3020_TIME5211461") at kinit.cpp:610
#46 0x0804f5c1 in handle_launcher_request (sock=8) at kinit.cpp:1174
#47 0x0804fc8a in handle_requests (waitForPid=0) at kinit.cpp:1375
#48 0x08051156 in main (argc=3, argv=0xfef075f4, envp=0xfef07604)
    at kinit.cpp:1828
Comment 4 Anders Lund 2004-10-28 22:40:58 UTC
I get the same crash, I'll ask laurence (who erote the xml indenter) when I see him.

In the meantime, you can turn the xml indenter off in the file type configuration.
Comment 5 Laurence Withers 2004-10-30 00:52:50 UTC
CVS commit by lwithers: 


Fix bug in XML autoindenter. When pasting a smaller file over a larger 
one, processSection() is actually called for each line in the larger file,
despite the fact that some of these lines may no longer exist.

Therefore, the patch catches this case and ensures that it cannot happen
(otherwise we dereference a null pointer).

BUG: 92284


  M +6 -2      kateautoindent.cpp   1.34


--- kdelibs/kate/part/kateautoindent.cpp  #1.33:1.34
@@ -1093,8 +1093,11 @@ void KateXmlIndent::processLine (KateDoc
 }
 
-void KateXmlIndent::processSection (KateDocCursor &begin, KateDocCursor &end)
+void KateXmlIndent::processSection (KateDocCursor &cur, KateDocCursor &end)
 {
   uint endLine = end.line();
-  for(uint line = begin.line(); line <= endLine; ++line) processLine(line);
+  do {
+    processLine(cur.line());
+    if(!cur.gotoNextLine()) break;
+  }while(cur.line() < endLine);
 }
 
@@ -1199,4 +1202,5 @@ uint KateXmlIndent::processLine (uint li
 {
   KateTextLine::Ptr kateLine = doc->plainKateTextLine(line);
+  if(!kateLine) return 0; // sanity check
 
   // get details from previous line