From fd79f88272d13c36e88199d276fea94f6b567a13 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 4 Oct 2016 12:08:11 +0100 Subject: crashtesting: use a stack with the expected dtor order for its elements contains test document which crashes if it doesn't Change-Id: Ieeee6cc7007a90d37225fffd636c9648289f04d7 --- include/o3tl/stack.hxx | 78 ++++++++++++++++++++++++++++++++ include/xmloff/xmlimp.hxx | 6 +-- sw/qa/core/data/xml/fail/ooo71273-1.sxw | Bin 0 -> 104936 bytes 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 include/o3tl/stack.hxx create mode 100644 sw/qa/core/data/xml/fail/ooo71273-1.sxw diff --git a/include/o3tl/stack.hxx b/include/o3tl/stack.hxx new file mode 100644 index 000000000000..1fa793481294 --- /dev/null +++ b/include/o3tl/stack.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#ifndef INCLUDED_O3TL_STACK_HXX +#define INCLUDED_O3TL_STACK_HXX + +#include + +namespace o3tl +{ + +/** + * + * Same as std::stack (it just wraps it) except at destruction time the + * container elements are destroyed in order starting from the top of the stack + * which is the order one would rather assume a stack uses, but doesn't have to + * + * https://connect.microsoft.com/VisualStudio/feedback/details/765649/std-vector-does-not-destruct-in-reverse-order-of-construction + * + **/ + +template class stack final +{ +private: + typedef std::stack stack_t; + + stack_t mStack; +public: + + T& top() + { + return mStack.top(); + } + + const T& top() const + { + return mStack.top(); + } + + void push(const T& val) + { + mStack.push(val); + } + + void push(T&& val) + { + mStack.push(val); + } + + void pop() + { + mStack.pop(); + } + + bool empty() const + { + return mStack.empty(); + } + + ~stack() + { + while (!mStack.empty()) + mStack.pop(); + } +}; + +} + +#endif /* INCLUDED_O3TL_STACK_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx index 07168bcf0b54..0aedd5b2a6f7 100644 --- a/include/xmloff/xmlimp.hxx +++ b/include/xmloff/xmlimp.hxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -86,8 +86,8 @@ class XMLErrors; class StyleMap; enum class SvXMLErrorFlags; -typedef std::stack SvXMLImportContexts_Impl; -typedef std::stack> +typedef o3tl::stack SvXMLImportContexts_Impl; +typedef o3tl::stack> FastSvXMLImportContexts_Impl; namespace xmloff { diff --git a/sw/qa/core/data/xml/fail/ooo71273-1.sxw b/sw/qa/core/data/xml/fail/ooo71273-1.sxw new file mode 100644 index 000000000000..5208512aae6f Binary files /dev/null and b/sw/qa/core/data/xml/fail/ooo71273-1.sxw differ -- cgit