hwpfilter/source/hbox.cxx        |  132 +++++++++++++++++++--------------------
 include/sfx2/frame.hxx           |    8 +-
 include/sfx2/objsh.hxx           |    6 -
 include/sfx2/viewfrm.hxx         |    8 +-
 include/sfx2/viewsh.hxx          |    8 +-
 sfx2/source/control/ctrlitem.cxx |    2 
 6 files changed, 82 insertions(+), 82 deletions(-)

New commits:
commit f18ca0794874d3bbdb570c803f3d190c8f34df37
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sun Dec 18 16:31:44 2022 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sun Dec 18 19:42:00 2022 +0000

    ofz#54402 check bounds
    
    git show -w
    
    Change-Id: I8e7c719a9f1c38f151eb7e59ec222849eb2e28f9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144402
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index e72c61434fb7..2e43d0f19691 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -615,78 +615,80 @@ OUString Outline::GetUnicode() const
                 {
                     char dest[80];
                     int l = 0;
-                    int i = level;
+                    unsigned i = level;
                     if( deco[i][0] ){
                         buffer[l++] = deco[i][0];
                     }
-/* level starts from zero. ex) '1.1.1.' is the level 2.
-   number has the value. ex) '1.2.1' has '1,2,1'
-   style has the value which starts from 1 according to the definition in 
hbox.h
- */
-                    switch( user_shape[i] )
+                    if (i < std::size(user_shape))
                     {
-                        case 0:
-                            buffer[l++] = '1' + number[i] - 1;
-                            break;
-                        case 1: /* Uppercase Roman */
-                        case 2: /* Lowercase Roman */
-                            num2roman(number[i], dest);
-                            if( user_shape[i] == 1 ){
-                                char *ptr = dest;
-                                while( *ptr )
-                                {
-                                    *ptr = 
sal::static_int_cast<char>(rtl::toAsciiUpperCase(static_cast<unsigned 
char>(*ptr)));
-                                    ptr++;
+                        /* level starts from zero. ex) '1.1.1.' is the level 2.
+                           number has the value. ex) '1.2.1' has '1,2,1'
+                           style has the value which starts from 1 according 
to the definition in hbox.h */
+                        switch( user_shape[i] )
+                        {
+                            case 0:
+                                buffer[l++] = '1' + number[i] - 1;
+                                break;
+                            case 1: /* Uppercase Roman */
+                            case 2: /* Lowercase Roman */
+                                num2roman(number[i], dest);
+                                if( user_shape[i] == 1 ){
+                                    char *ptr = dest;
+                                    while( *ptr )
+                                    {
+                                        *ptr = 
sal::static_int_cast<char>(rtl::toAsciiUpperCase(static_cast<unsigned 
char>(*ptr)));
+                                        ptr++;
+                                    }
                                 }
+                                str2hstr(dest, buffer + l);
+                                l += strlen(dest);
+                                break;
+                            case 3:
+                                buffer[l++] = 'A' + number[i] -1;
+                                break;
+                            case 4:
+                                buffer[l++] = 'a' + number[i] -1;
+                                break;
+                            case 5:
+                                buffer[l++] = olHanglJaso(number[i] -1, 
OL_HANGL_KANATA);
+                                break;
+                            case 6:
+                                buffer[l++] = olHanglJaso(number[i] -1, 
OL_HANGL_JASO);
+                                break;
+                            case 7: /* Chinese numbers: the number represented 
by the general */
+                                buffer[l++] = '1' + number[i] -1;
+                                break;
+                            case 8: /* Circled numbers */
+                                buffer[l++] = 0x2e00 + number[i];
+                                break;
+                            case 9: /* Circled lowercase alphabet */
+                                buffer[l++] = 0x2c20 + number[i];
+                                break;
+                            case 10: /* Circled Korean Alphabet */
+                                buffer[l++] = 0x2c50 + number[i] -1;
+                                break;
+                            case 11: /* Circled Korean Characters */
+                                buffer[l++] = 0x2c40 + number[i] -1;
+                                break;
+                            case 12: /* Sequenced numbers. */
+                            {
+                                 OStringBuffer buf;
+                                 int j;
+                                 for (j = 0; j <= level; j++)
+                                 {
+                                      levelnum = ((number[j] < 1) ? 1 : 
number[j]);
+                                      buf.append(OString::number(levelnum));
+                                      if (!((j && j == level) || (j == level 
&& deco[i][1])))
+                                            buf.append('.');
+                                 }
+                                 str2hstr(buf.getStr(), buffer + l);
+                                 l += buf.getLength();
+                                 break;
                             }
-                            str2hstr(dest, buffer + l);
-                            l += strlen(dest);
-                            break;
-                        case 3:
-                            buffer[l++] = 'A' + number[i] -1;
-                            break;
-                        case 4:
-                            buffer[l++] = 'a' + number[i] -1;
-                            break;
-                        case 5:
-                            buffer[l++] = olHanglJaso(number[i] -1, 
OL_HANGL_KANATA);
-                            break;
-                        case 6:
-                            buffer[l++] = olHanglJaso(number[i] -1, 
OL_HANGL_JASO);
-                            break;
-                        case 7: /* Chinese numbers: the number represented by 
the general */
-                            buffer[l++] = '1' + number[i] -1;
-                            break;
-                        case 8: /* Circled numbers */
-                            buffer[l++] = 0x2e00 + number[i];
-                            break;
-                        case 9: /* Circled lowercase alphabet */
-                            buffer[l++] = 0x2c20 + number[i];
-                            break;
-                        case 10: /* Circled Korean Alphabet */
-                            buffer[l++] = 0x2c50 + number[i] -1;
-                            break;
-                        case 11: /* Circled Korean Characters */
-                            buffer[l++] = 0x2c40 + number[i] -1;
-                            break;
-                        case 12: /* Sequenced numbers. */
-                        {
-                             OStringBuffer buf;
-                             int j;
-                             for (j = 0; j <= level; j++)
-                             {
-                                  levelnum = ((number[j] < 1) ? 1 : number[j]);
-                                  buf.append(OString::number(levelnum));
-                                  if (!((j && j == level) || (j == level && 
deco[i][1])))
-                                        buf.append('.');
-                             }
-                             str2hstr(buf.getStr(), buffer + l);
-                             l += buf.getLength();
-                             break;
+                            default:
+                                buffer[l++] = user_shape[i];
+                                break;
                         }
-                        default:
-                            buffer[l++] = user_shape[i];
-                            break;
                     }
                     if( deco[i][1] ){
                         buffer[l++] = deco[i][1];
commit 00c90e648c0bf5033ad51dc5cb495e788ecdd418
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sun Dec 18 10:51:11 2022 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Sun Dec 18 19:41:50 2022 +0000

    add some SAL_WARN_UNUSED_RESULT
    
    commit 817dfb74d9ec9f46ba32be6d5066d534f81072a5
    Date:   Tue Jul 17 09:45:37 2001 +0000
    
        #89783#: NULL-Ptr possible
    
    probably intended
    
    pViewFrame = SfxViewFrame::GetFirst()
    
    but at this distance in time, just accept the current state
    of things
    
    Change-Id: I8779fef1041843e9f2e6c879cfb475d8ac8251fd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144401
    Tested-by: Caolán McNamara <[email protected]>
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/include/sfx2/frame.hxx b/include/sfx2/frame.hxx
index d13499c2fdfd..888a1631f80e 100644
--- a/include/sfx2/frame.hxx
+++ b/include/sfx2/frame.hxx
@@ -89,11 +89,11 @@ public:
     void                SetPresentationMode( bool bSet );
     SystemWindow*       GetSystemWindow() const;
 
-    static SfxFrame*    GetFirst();
-    static SfxFrame*    GetNext( SfxFrame& );
+    SAL_WARN_UNUSED_RESULT static SfxFrame* GetFirst();
+    SAL_WARN_UNUSED_RESULT static SfxFrame* GetNext( SfxFrame& );
 
-    SfxObjectShell*     GetCurrentDocument() const;
-    SfxViewFrame*       GetCurrentViewFrame() const;
+    SAL_WARN_UNUSED_RESULT SfxObjectShell* GetCurrentDocument() const;
+    SAL_WARN_UNUSED_RESULT SfxViewFrame* GetCurrentViewFrame() const;
 
     bool                GetHasTitle() const;
     static void         GetDefaultTargetList( TargetList& );
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index ef1a0a33e1dc..b64fa61389bf 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -238,12 +238,12 @@ public:
     static OUString CreateShellID( const SfxObjectShell* pShell );
 
     // Document-Shell Iterator
-    static SfxObjectShell*      GetFirst( const std::function<bool ( const 
SfxObjectShell* )>& isObjectShell = nullptr,
+    SAL_WARN_UNUSED_RESULT static SfxObjectShell* GetFirst( const 
std::function<bool ( const SfxObjectShell* )>& isObjectShell = nullptr,
                                           bool bOnlyVisible = true );
-    static SfxObjectShell*      GetNext( const SfxObjectShell& rPrev,
+    SAL_WARN_UNUSED_RESULT static SfxObjectShell* GetNext( const 
SfxObjectShell& rPrev,
                                          const std::function<bool ( const 
SfxObjectShell* )>& isObjectShell = nullptr,
                                          bool bOnlyVisible = true );
-    static SfxObjectShell*      Current();
+    SAL_WARN_UNUSED_RESULT static SfxObjectShell* Current();
     static css::uno::Reference< css::uno::XInterface >
                                 GetCurrentComponent();
     static void                 SetCurrentComponent( const 
css::uno::Reference< css::uno::XInterface >& _rxComponent );
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index d8b15faa1762..a5deb63a7ebf 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -96,11 +96,11 @@ public:
     static SfxViewFrame*    LoadDocumentIntoFrame( SfxObjectShell const & 
i_rDoc, const css::uno::Reference< css::frame::XFrame >& i_rFrameItem );
     static SfxViewFrame*    DisplayNewDocument( SfxObjectShell const & i_rDoc, 
const SfxRequest& i_rCreateDocRequest );
 
-    static SfxViewFrame*    Current();
-    static SfxViewFrame*    GetFirst( const SfxObjectShell* pDoc = nullptr, 
bool bOnlyVisible = true );
-    static SfxViewFrame*    GetNext( const SfxViewFrame& rPrev, const 
SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true );
+    SAL_WARN_UNUSED_RESULT static SfxViewFrame* Current();
+    SAL_WARN_UNUSED_RESULT static SfxViewFrame* GetFirst( const 
SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true );
+    SAL_WARN_UNUSED_RESULT static SfxViewFrame* GetNext( const SfxViewFrame& 
rPrev, const SfxObjectShell* pDoc = nullptr, bool bOnlyVisible = true );
 
-    static SfxViewFrame*    Get( const css::uno::Reference< 
css::frame::XController>& i_rController, const SfxObjectShell* i_pDoc );
+    SAL_WARN_UNUSED_RESULT static SfxViewFrame* Get( const 
css::uno::Reference< css::frame::XController>& i_rController, const 
SfxObjectShell* i_pDoc );
 
             void            DoActivate(bool bMDI);
             void            DoDeactivate(bool bMDI, SfxViewFrame const *pOld);
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 975076a1fd51..5c8e8b1152f8 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -187,13 +187,13 @@ protected:
 
 public:
     // Iteration
-    static SfxViewShell*        GetFirst( bool bOnlyVisible = true, const 
std::function<bool ( const SfxViewShell* )>& isViewShell = nullptr );
-    static SfxViewShell*        GetNext( const SfxViewShell& rPrev,
+    SAL_WARN_UNUSED_RESULT static SfxViewShell* GetFirst( bool bOnlyVisible = 
true, const std::function<bool ( const SfxViewShell* )>& isViewShell = nullptr 
);
+    SAL_WARN_UNUSED_RESULT static SfxViewShell* GetNext( const SfxViewShell& 
rPrev,
                                          bool bOnlyVisible = true,
                                          const std::function<bool ( const 
SfxViewShell* )>& isViewShell = nullptr );
-    static SfxViewShell*        Current();
+    SAL_WARN_UNUSED_RESULT static SfxViewShell* Current();
 
-    static SfxViewShell*        Get( const css::uno::Reference< 
css::frame::XController>& i_rController );
+    SAL_WARN_UNUSED_RESULT static SfxViewShell* Get( const 
css::uno::Reference< css::frame::XController>& i_rController );
 
     // Initialize Constructors/Destructors
                                 SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWSH)
diff --git a/sfx2/source/control/ctrlitem.cxx b/sfx2/source/control/ctrlitem.cxx
index 28edfec666de..1e5dc277909b 100644
--- a/sfx2/source/control/ctrlitem.cxx
+++ b/sfx2/source/control/ctrlitem.cxx
@@ -314,8 +314,6 @@ MapUnit SfxControllerItem::GetCoreMetric() const
     if ( !pDispat )
     {
         SfxViewFrame* pViewFrame = SfxViewFrame::Current();
-        if ( !pViewFrame )
-            SfxViewFrame::GetFirst();
         if ( pViewFrame )
             pDispat = pViewFrame->GetDispatcher();
     }

Reply via email to