diff options
author | Pranav Kant <pranavk@libreoffice.org> | 2016-01-10 22:50:46 +0530 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2016-01-11 11:19:46 +0000 |
commit | 02b49890d51ec463d32846f1108344159664a9eb (patch) | |
tree | 55107d328952aaa1626d4a5cabddafef4960f8d7 /libreofficekit | |
parent | loplugin:unusedmethods unused return value in framework (diff) | |
download | core-02b49890d51ec463d32846f1108344159664a9eb.tar.gz core-02b49890d51ec463d32846f1108344159664a9eb.zip |
lokdocview: Use shared_ptr to fix a possible memory leak
Possible because boost::property_tree can throw an exception.
Change-Id: I68394ce3b30d448d40d8e22555bafdff1ffa6092
Reviewed-on: https://gerrit.libreoffice.org/21309
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 168338d03d48..5df774601995 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -10,6 +10,7 @@ #include <sal/types.h> #include <math.h> #include <string.h> +#include <memory> #include <vector> #include <string> #include <iostream> @@ -343,13 +344,12 @@ doSearch(LOKDocView* pDocView, const char* pText, bool bBackwards, bool highligh boost::property_tree::ptree aTree; GtkWidget* drawingWidget = GTK_WIDGET(pDocView); GdkWindow* drawingWindow = gtk_widget_get_window(drawingWidget); - cairo_region_t* cairoVisRegion = gdk_window_get_visible_region(drawingWindow); + std::shared_ptr<cairo_region_t> cairoVisRegion( gdk_window_get_visible_region(drawingWindow), + cairo_region_destroy); cairo_rectangle_int_t cairoVisRect; - int x, y; - - cairo_region_get_rectangle(cairoVisRegion, 0, &cairoVisRect); - x = pixelToTwip (cairoVisRect.x, priv->m_fZoom); - y = pixelToTwip (cairoVisRect.y, priv->m_fZoom); + cairo_region_get_rectangle(cairoVisRegion.get(), 0, &cairoVisRect); + int x = pixelToTwip (cairoVisRect.x, priv->m_fZoom); + int y = pixelToTwip (cairoVisRect.y, priv->m_fZoom); aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/type", '/'), "string"); aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchString/value", '/'), pText); |