diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-03-20 11:31:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-03-21 08:36:05 +0000 |
commit | fd32093df9fdf5d46ed4def9fd8dada7d0d5e361 (patch) | |
tree | ce9ba87158b4973de882980438975c4cf2788a73 | |
parent | 8bc607225e6bc9ba343e2292f9185b6491108e44 (diff) |
tdf#154232 signal_drag_begin callback can delete current GtkTargetList
so fetch the up to date one on calling gtk_drag_begin_with_coordinates
==3221972== Invalid read of size 8
==3221972== at 0x23F281DA: gtk_drag_begin_internal (gtkdnd.c:1801)
==3221972== by 0x23F2886F: gtk_drag_begin_with_coordinates (gtkdnd.c:1995)
==3221972== by 0x23845075: (anonymous namespace)::GtkInstanceWidget::signal_motion(_GdkEventMotion const*) (gtkinst.cxx:3139)
==3221972== by 0x23844F09: (anonymous namespace)::GtkInstanceWidget::signalMotion(_GtkWidget*, _GdkEventMotion*, void*) (gtkinst.cxx:3130)
==3221972== by 0x23C0FC56: _gtk_marshal_BOOLEAN__BOXED (gtkmarshalers.c:84)
==3221972== by 0x1378C05F: g_closure_invoke (gclosure.c:832)
==3221972== by 0x137B8F65: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
==3221972== by 0x137A8ED5: g_signal_emit_valist (gsignal.c:3559)
==3221972== by 0x137A96F2: g_signal_emit (gsignal.c:3606)
==3221972== by 0x23EF1073: gtk_widget_event_internal.part.0.lto_priv.0 (gtkwidget.c:7812)
==3221972== by 0x23D825AD: UnknownInlinedFun (gtkmain.c:2588)
==3221972== by 0x23D825AD: propagate_event.lto_priv.0 (gtkmain.c:2691)
==3221972== by 0x23D83320: UnknownInlinedFun (gtkmain.c:1921)
==3221972== by 0x23D83320: gtk_main_do_event (gtkmain.c:1691)
==3221972== Address 0x2c7d8070 is 0 bytes inside a block of size 16 free'd
==3221972== at 0x48460E4: free (vg_replace_malloc.c:884)
==3221972== by 0x1383388C: g_free (gmem.c:229)
==3221972== by 0x1384E093: g_slice_free1 (gslice.c:1185)
==3221972== by 0x23CD7A08: gtk_drag_source_set (gtkdragsource.c:162)
==3221972== by 0x23ED1EAB: gtk_tree_view_enable_model_drag_source (gtktreeview.c:14303)
==3221972== by 0x23877F41: (anonymous namespace)::GtkInstanceTreeView::drag_source_set(std::__debug::vector<_GtkTargetEntry, std::allocator<_GtkTargetEntry> > const&, GdkDragAction) (gtkinst.cxx:16279)
==3221972== by 0x238440B3: (anonymous namespace)::GtkInstanceWidget::do_enable_drag_source(rtl::Reference<TransferDataContainer> const&, unsigned char) (gtkinst.cxx:2707)
==3221972== by 0x23877E99: (anonymous namespace)::GtkInstanceTreeView::enable_drag_source(rtl::Reference<TransferDataContainer>&, unsigned char) (gtkinst.cxx:16270)
==3221972== by 0x36AAE6D2: SwContentTree::DragBeginHdl(bool&) (content.cxx:1227)
==3221972== by 0x36AAE2CE: SwContentTree::LinkStubDragBeginHdl(void*, bool&) (content.cxx:1180)
==3221972== by 0x238D38DA: Link<bool&, bool>::Call(bool&) const (link.hxx:111)
==3221972== by 0x23878D2D: (anonymous namespace)::GtkInstanceTreeView::do_signal_drag_begin(bool&) (gtkinst.cxx:16520)
Change-Id: Idffa33c6a549bf17a92eb56760ddfb7d5424b7ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149155
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 3177ec5272d2..5fe9ff9779fe 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -3132,12 +3132,12 @@ private: bool signal_motion(const GdkEventMotion* pEvent) { - GtkTargetList* pDragData = (m_eDragAction != 0 && m_nPressedButton != -1 && m_xDragSource.is()) ? gtk_drag_source_get_target_list(m_pWidget) : nullptr; + const bool bDragData = m_eDragAction != 0 && m_nPressedButton != -1 && m_xDragSource.is() && gtk_drag_source_get_target_list(m_pWidget); bool bUnsetDragIcon(false); - if (pDragData && gtk_drag_check_threshold(m_pWidget, m_nPressStartX, m_nPressStartY, pEvent->x, pEvent->y) && !do_signal_drag_begin(bUnsetDragIcon)) + if (bDragData && gtk_drag_check_threshold(m_pWidget, m_nPressStartX, m_nPressStartY, pEvent->x, pEvent->y) && !do_signal_drag_begin(bUnsetDragIcon)) { GdkDragContext* pContext = gtk_drag_begin_with_coordinates(m_pWidget, - pDragData, + gtk_drag_source_get_target_list(m_pWidget), m_eDragAction, m_nPressedButton, const_cast<GdkEvent*>(reinterpret_cast<const GdkEvent*>(pEvent)), |