vcl/unx/generic/printer/ppdparser.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
New commits: commit 4058d85963e371be657f531d8f30e31381a9ccab Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Nov 5 15:17:47 2017 -0500 PPDCache: fix segfault due to access after delete Regression introduced in: commit afe4d2527ec72e7493a2b1431559652ef45bebab Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Wed Oct 18 09:43:21 2017 +0200 use std::unique_ptr in PPDCache Removing a naked pointer before inserting a possibly existing one in a container is safe. This insured uniqueness (as the comment suggests). However with unique_ptr, removal before inserting deletes the pointer (when it exists), and the insertion now taints the container with a wild pointer. The fix is to skip adding if the pointer is already in the container and add only when missing. Change-Id: Ifc6b517451abb564949ccadfee10d98bf827540d Reviewed-on: https://gerrit.libreoffice.org/44333 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index d8bbd11e4b50..a2d8f45c8c42 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -576,15 +576,15 @@ const PPDParser* PPDParser::getParser( const OUString& rFile ) if( pNewParser ) { // this may actually be the SGENPRT parser, - // so ensure uniqueness here - rPPDCache.aAllParsers.erase( - std::remove_if( + // so ensure uniqueness here (but don't remove lest we delete us!) + if (std::find_if( rPPDCache.aAllParsers.begin(), rPPDCache.aAllParsers.end(), - [pNewParser] (std::unique_ptr<PPDParser> const & x) { return x.get() == pNewParser; } ), - rPPDCache.aAllParsers.end()); - // insert new parser to vector - rPPDCache.aAllParsers.emplace_back(pNewParser); + [pNewParser] (std::unique_ptr<PPDParser> const & x) { return x.get() == pNewParser; } ) == rPPDCache.aAllParsers.end()) + { + // insert new parser to vector + rPPDCache.aAllParsers.emplace_back(pNewParser); + } } return pNewParser; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits