Changeset 51627 in webkit


Ignore:
Timestamp:
Dec 3, 2009 1:22:14 AM (14 years ago)
Author:
oliver@apple.com
Message:

NULL ptr in SVGPathSegList::getPathSegAtLength()
https://bugs.webkit.org/show_bug.cgi?id=30313

Reviewed by Maciej Stachowiak.

Add exception checks to SVGPathSegList's implementation to catch (and propagate) exceptions.
Add null checks to SVGList's content manipulation functions to prevent
null values from entering the list in the first place.

Test: svg/dom/svgpath-out-of-bounds-getPathSeg.html

Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r51626 r51627  
     12009-12-03  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        NULL ptr in SVGPathSegList::getPathSegAtLength()
     6        https://bugs.webkit.org/show_bug.cgi?id=30313
     7
     8        Add testcases for incorrect pathSeg usage.
     9
     10        * svg/dom/svgpath-out-of-bounds-getPathSeg-expected.txt: Added.
     11        * svg/dom/svgpath-out-of-bounds-getPathSeg.html: Added.
     12
    1132009-12-02  Shinichiro Hamaji  <hamaji@chromium.org>
    214
  • trunk/WebCore/ChangeLog

    r51623 r51627  
     12009-12-03  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        NULL ptr in SVGPathSegList::getPathSegAtLength()
     6        https://bugs.webkit.org/show_bug.cgi?id=30313
     7
     8        Add exception checks to SVGPathSegList's implementation to catch (and propagate) exceptions.
     9        Add null checks to SVGList's content manipulation functions to prevent
     10        null values from entering the list in the first place.
     11
     12        Test: svg/dom/svgpath-out-of-bounds-getPathSeg.html
     13
     14        * svg/SVGList.h:
     15        (WebCore::SVGList::initialize):
     16        (WebCore::SVGList::insertItemBefore):
     17        (WebCore::SVGList::replaceItem):
     18        (WebCore::SVGList::appendItem):
     19        * svg/SVGPathElement.cpp:
     20        (WebCore::SVGPathElement::getPathSegAtLength):
     21        * svg/SVGPathElement.h:
     22        * svg/SVGPathElement.idl:
     23        * svg/SVGPathSegList.cpp:
     24        (WebCore::SVGPathSegList::getPathSegAtLength):
     25        (WebCore::SVGPathSegList::toPathData):
     26        (WebCore::SVGPathSegList::createAnimated):
     27        * svg/SVGPathSegList.h:
     28
    1292009-12-02  Yusuke Sato  <yusukes@chromium.org>
    230
  • trunk/WebCore/svg/SVGList.h

    r50583 r51627  
    5757        Item initialize(Item newItem, ExceptionCode& ec)
    5858        {
     59            if (!newItem) {
     60                ec = TYPE_MISMATCH_ERR;
     61                return TypeOperations::nullItem();
     62            }
    5963            clear(ec);
    6064            return appendItem(newItem, ec);
     
    9397        }
    9498
    95         Item insertItemBefore(Item newItem, unsigned int index, ExceptionCode&)
    96         {
     99        Item insertItemBefore(Item newItem, unsigned int index, ExceptionCode& ec)
     100        {
     101            if (!newItem) {
     102                ec = TYPE_MISMATCH_ERR;
     103                return TypeOperations::nullItem();
     104            }
     105
    97106            if (index < m_vector.size()) {
    98107                m_vector.insert(index, newItem);
     
    109118                return TypeOperations::nullItem();
    110119            }
     120   
     121            if (!newItem) {
     122                ec = TYPE_MISMATCH_ERR;
     123                return TypeOperations::nullItem();
     124            }
    111125
    112126            m_vector[index] = newItem;
     
    126140        }
    127141
    128         Item appendItem(Item newItem, ExceptionCode&)
    129         {
     142        Item appendItem(Item newItem, ExceptionCode& ec)
     143        {
     144            if (!newItem) {
     145                ec = TYPE_MISMATCH_ERR;
     146                return TypeOperations::nullItem();
     147            }
     148
    130149            m_vector.append(newItem);
    131150            return newItem;
  • trunk/WebCore/svg/SVGPathElement.cpp

    r50583 r51627  
    7070}
    7171
    72 unsigned long SVGPathElement::getPathSegAtLength(float length)
    73 {
    74     return pathSegList()->getPathSegAtLength(length);
     72unsigned long SVGPathElement::getPathSegAtLength(float length, ExceptionCode& ec)
     73{
     74    return pathSegList()->getPathSegAtLength(length, ec);
    7575}
    7676
  • trunk/WebCore/svg/SVGPathElement.h

    r49602 r51627  
    6363        float getTotalLength();
    6464        FloatPoint getPointAtLength(float distance);
    65         unsigned long getPathSegAtLength(float distance);
     65        unsigned long getPathSegAtLength(float distance, ExceptionCode&);
    6666
    6767        static PassRefPtr<SVGPathSegClosePath> createSVGPathSegClosePath();
  • trunk/WebCore/svg/SVGPathElement.idl

    r16982 r51627  
    3838        float getTotalLength();
    3939        SVGPoint getPointAtLength(in float distance);
    40         unsigned long getPathSegAtLength(in float distance);
     40        unsigned long getPathSegAtLength(in float distance)
     41            raises(DOMException, SVGException);
    4142
    4243        SVGPathSegClosePath createSVGPathSegClosePath();
  • trunk/WebCore/svg/SVGPathSegList.cpp

    r36406 r51627  
    5252}
    5353
    54 unsigned SVGPathSegList::getPathSegAtLength(double)
     54unsigned SVGPathSegList::getPathSegAtLength(double, ExceptionCode& ec)
    5555{
    5656    // FIXME : to be useful this will need to support non-normalized SVGPathSegLists
    57     ExceptionCode ec = 0;
    5857    int len = numberOfItems();
    5958    // FIXME: Eventually this will likely move to a "path applier"-like model, until then PathTraversalState is less useful as we could just use locals
     
    6160    for (int i = 0; i < len; ++i) {
    6261        SVGPathSeg* segment = getItem(i, ec).get();
     62        if (ec)
     63            return 0;
    6364        float segmentLength = 0;
    6465        switch (segment->pathSegType()) {
     
    105106    // FIXME : This should also support non-normalized PathSegLists
    106107    Path pathData;
     108    int len = numberOfItems();
    107109    ExceptionCode ec = 0;
    108     int len = numberOfItems();
    109110    for (int i = 0; i < len; ++i) {
    110111        SVGPathSeg* segment = getItem(i, ec).get();
     112        if (ec)
     113            return Path();
    111114        switch (segment->pathSegType()) {
    112115            case SVGPathSeg::PATHSEG_MOVETO_ABS:
     
    183186        return 0;
    184187    RefPtr<SVGPathSegList> result = create(fromList->associatedAttributeName());
    185     ExceptionCode ec;
     188    ExceptionCode ec = 0;
    186189    for (unsigned n = 0; n < itemCount; ++n) {
    187190        SVGPathSeg* from = fromList->getItem(n, ec).get();
     191        if (ec)
     192            return 0;
    188193        SVGPathSeg* to = toList->getItem(n, ec).get();
     194        if (ec)
     195            return 0;
    189196        if (from->pathSegType() == SVGPathSeg::PATHSEG_UNKNOWN || from->pathSegType() != to->pathSegType())
    190197            return 0;
     
    252259        }
    253260        result->appendItem(segment, ec);
     261        if (ec)
     262            return 0;
    254263    }
    255264    return result.release();
  • trunk/WebCore/svg/SVGPathSegList.h

    r34358 r51627  
    3737        virtual ~SVGPathSegList();
    3838
    39         unsigned getPathSegAtLength(double);
     39        unsigned getPathSegAtLength(double, ExceptionCode&);
    4040        Path toPathData();
    4141       
Note: See TracChangeset for help on using the changeset viewer.