Changeset 206048 in webkit


Ignore:
Timestamp:
Sep 16, 2016 2:20:23 PM (8 years ago)
Author:
Brent Fulgham
Message:

CaptionUserPreferences's use of the PageGroup's page map is incorrect
https://bugs.webkit.org/show_bug.cgi?id=122194
<rdar://problem/27332004>

Reviewed by Zalan Bujtas.

Avoid the possibility of dereferencing an unsafe iterator by checking
for an empty HashSet before using the result of 'begin()'.

No new tests because there is no change in behavior.

  • page/CaptionUserPreferences.cpp:

(WebCore::CaptionUserPreferences::CaptionUserPreferences): Use new safer
accessor to retrieve the current page.
(WebCore::CaptionUserPreferences::setCaptionDisplayMode): Ditto.
(WebCore::CaptionUserPreferences::currentPage): Added.
(WebCore::CaptionUserPreferences::userPrefersCaptions): Use new safer
accessor to retrieve the current page.
(WebCore::CaptionUserPreferences::setUserPrefersCaptions): Ditto.
(WebCore::CaptionUserPreferences::userPrefersSubtitles): Ditto.
(WebCore::CaptionUserPreferences::setUserPrefersSubtitles): Ditto.
(WebCore::CaptionUserPreferences::userPrefersTextDescriptions): Ditto.
(WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions): Ditto.

  • page/CaptionUserPreferences.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206044 r206048  
     12016-09-16  Brent Fulgham  <bfulgham@apple.com>
     2
     3        CaptionUserPreferences's use of the PageGroup's page map is incorrect
     4        https://bugs.webkit.org/show_bug.cgi?id=122194
     5        <rdar://problem/27332004>
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        Avoid the possibility of dereferencing an unsafe iterator by checking
     10        for an empty HashSet before using the result of 'begin()'.
     11
     12        No new tests because there is no change in behavior.
     13
     14        * page/CaptionUserPreferences.cpp:
     15        (WebCore::CaptionUserPreferences::CaptionUserPreferences): Use new safer
     16        accessor to retrieve the current page.
     17        (WebCore::CaptionUserPreferences::setCaptionDisplayMode): Ditto.
     18        (WebCore::CaptionUserPreferences::currentPage): Added.
     19        (WebCore::CaptionUserPreferences::userPrefersCaptions): Use new safer
     20        accessor to retrieve the current page.
     21        (WebCore::CaptionUserPreferences::setUserPrefersCaptions): Ditto.
     22        (WebCore::CaptionUserPreferences::userPrefersSubtitles): Ditto.
     23        (WebCore::CaptionUserPreferences::setUserPrefersSubtitles): Ditto.
     24        (WebCore::CaptionUserPreferences::userPrefersTextDescriptions): Ditto.
     25        (WebCore::CaptionUserPreferences::setUserPrefersTextDescriptions): Ditto.
     26        * page/CaptionUserPreferences.h:
     27
    1282016-09-16  Alex Christensen  <achristensen@webkit.org>
    229
  • trunk/Source/WebCore/page/CaptionUserPreferences.cpp

    r205462 r206048  
    11/*
    2  * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5050    , m_displayMode(ForcedOnly)
    5151    , m_timer(*this, &CaptionUserPreferences::timerFired)
    52     , m_testingMode(false)
    53     , m_havePreferences(false)
    5452{
    5553}
     
    10098}
    10199
     100Page* CaptionUserPreferences::currentPage() const
     101{
     102    if (m_pageGroup.pages().isEmpty())
     103        return nullptr;
     104
     105    return *(m_pageGroup.pages().begin());
     106}
     107
    102108bool CaptionUserPreferences::userPrefersCaptions() const
    103109{
    104     Page* page = *(m_pageGroup.pages().begin());
     110    Page* page = currentPage();
    105111    if (!page)
    106112        return false;
     
    111117void CaptionUserPreferences::setUserPrefersCaptions(bool preference)
    112118{
    113     Page* page = *(m_pageGroup.pages().begin());
     119    Page* page = currentPage();
    114120    if (!page)
    115121        return;
     
    121127bool CaptionUserPreferences::userPrefersSubtitles() const
    122128{
    123     Page* page = *(pageGroup().pages().begin());
     129    Page* page = currentPage();
    124130    if (!page)
    125131        return false;
     
    130136void CaptionUserPreferences::setUserPrefersSubtitles(bool preference)
    131137{
    132     Page* page = *(m_pageGroup.pages().begin());
     138    Page* page = currentPage();
    133139    if (!page)
    134140        return;
     
    140146bool CaptionUserPreferences::userPrefersTextDescriptions() const
    141147{
    142     Page* page = *(m_pageGroup.pages().begin());
     148    Page* page = currentPage();
    143149    if (!page)
    144150        return false;
     
    149155void CaptionUserPreferences::setUserPrefersTextDescriptions(bool preference)
    150156{
    151     Page* page = *(m_pageGroup.pages().begin());
     157    Page* page = currentPage();
    152158    if (!page)
    153159        return;
  • trunk/Source/WebCore/page/CaptionUserPreferences.h

    r200673 r206048  
    11/*
    2  * Copyright (C) 2012, 2013  Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2016  Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef CaptionUserPreferences_h
    27 #define CaptionUserPreferences_h
     26#pragma once
    2827
    2928#if ENABLE(VIDEO_TRACK)
     
    106105    void timerFired();
    107106    void notify();
     107    Page* currentPage() const;
    108108
    109109    PageGroup& m_pageGroup;
     
    115115    String m_primaryAudioTrackLanguageOverride;
    116116    unsigned m_blockNotificationsCounter { 0 };
    117     bool m_testingMode;
    118     bool m_havePreferences;
     117    bool m_testingMode { false };
     118    bool m_havePreferences { false };
    119119};
    120120   
    121121}
    122122#endif
    123 
    124 #endif
Note: See TracChangeset for help on using the changeset viewer.