[Libreoffice-commits] core.git: libreofficekit/source
Pranav Kant
pranavk at libreoffice.org
Mon Jan 11 03:20:11 PST 2016
libreofficekit/source/gtk/lokdocview.cxx | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
New commits:
commit 02b49890d51ec463d32846f1108344159664a9eb
Author: Pranav Kant <pranavk at libreoffice.org>
Date: Sun Jan 10 22:50:46 2016 +0530
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 at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 168338d..5df7746 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);
More information about the Libreoffice-commits
mailing list