Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Side by Side Diff: Source/core/rendering/OrderIterator.h

Issue 19558006: Heap-use-after-free in WebCore::RenderFlexibleBox::firstLineBoxBaseline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated change after the review's comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 public: 54 public:
55 friend class OrderIteratorPopulator; 55 friend class OrderIteratorPopulator;
56 56
57 OrderIterator(const RenderBox*); 57 OrderIterator(const RenderBox*);
58 58
59 RenderBox* currentChild() const { return m_currentChild; } 59 RenderBox* currentChild() const { return m_currentChild; }
60 RenderBox* first(); 60 RenderBox* first();
61 RenderBox* next(); 61 RenderBox* next();
62 void reset(); 62 void reset();
63 63
64 void invalidate();
65
64 private: 66 private:
65 const RenderBox* m_containerBox; 67 const RenderBox* m_containerBox;
66 68
67 // The inline capacity for a single item is used to cover the most 69 // The inline capacity for a single item is used to cover the most
68 // common case by far: if we only have the default 'order' value 0. 70 // common case by far: if we only have the default 'order' value 0.
69 typedef Vector<int, 1> OrderValues; 71 typedef Vector<int, 1> OrderValues;
70 OrderValues m_orderValues; 72 OrderValues m_orderValues;
71 73
72 RenderBox* m_currentChild; 74 RenderBox* m_currentChild;
73 size_t m_currentOrderIndex; 75 size_t m_currentOrderIndex;
74 size_t m_currentChildIndex; 76 size_t m_currentChildIndex;
75 77
76 // This HashMap is empty if there is only one value. 78 // This HashMap is empty if there is only one value.
77 typedef HashMap<int, Vector<RenderBox*>, DefaultHash<int>::Hash, OrdererValu eMapKeyHashTraits > OrderedValuesMap; 79 typedef HashMap<int, Vector<RenderBox*>, DefaultHash<int>::Hash, OrdererValu eMapKeyHashTraits > OrderedValuesMap;
78 OrderedValuesMap m_orderedValues; 80 OrderedValuesMap m_orderedValues;
79 }; 81 };
80 82
81 class OrderIteratorPopulator { 83 class OrderIteratorPopulator {
82 public: 84 public:
83 OrderIteratorPopulator(OrderIterator& iterator) 85 OrderIteratorPopulator(OrderIterator& iterator)
84 : m_iterator(iterator) 86 : m_iterator(iterator)
85 { 87 {
86 // Note that we don't release the memory here, we only invalidate the si ze. 88 m_iterator.invalidate();
87 // This avoids unneeded reallocation if the size ends up not changing.
88 m_iterator.m_orderValues.shrink(0);
89 m_iterator.m_orderedValues.clear();
90 } 89 }
91 90
92 ~OrderIteratorPopulator(); 91 ~OrderIteratorPopulator();
93 92
94 void collectChild(RenderBox*); 93 void collectChild(RenderBox*);
95 94
96 private: 95 private:
97 OrderIterator& m_iterator; 96 OrderIterator& m_iterator;
98 }; 97 };
99 98
100 } // namespace WebCore 99 } // namespace WebCore
101 100
102 #endif // OrderIterator_h 101 #endif // OrderIterator_h
OLDNEW
« no previous file with comments | « LayoutTests/fast/flexbox/order-iterator-crash-expected.txt ('k') | Source/core/rendering/OrderIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698