Project Name | CID | Checker | Category | Developer Description |
---|---|---|---|---|
OpenOffice | 705753 | RESOURCE_LEAK | Resource leaks | Memory leak: Coverity has found around 20! |
2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 |
{ bRet = true; } } return bRet; } sal_uInt16 lcl_GetMaxValidWordTOCLevel(const SwForm &rForm) { // GetFormMax() returns level + 1, hence the -1 sal_uInt16 nRet = rForm.GetFormMax()-1; // If the max of this type of TOC is greater than the max of a word // possible toc, then clip to the word max if (nRet > WW8ListManager::nMaxLevel) nRet = WW8ListManager::nMaxLevel; return nRet; } eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) { mbLoadingTOCCache = true; |
< 1. Condition "pF->nLRes < 3", taking false branch
2997 2998 2999 3000 |
if (pF->nLRes < 3) return FLD_TEXT; // ignore (#i25440#) TOXTypes eTox; // Baue ToxBase zusammen |
< 2. Switch case value "13"
3001 3002 3003 3004 3005 3006 3007 |
switch( pF->nId ) { case 8: eTox = TOX_INDEX; break; case 13: eTox = TOX_CONTENT; |
< 3. Breaking from switch
3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 |
break; default: eTox = TOX_USER; break; } sal_uInt16 nCreateOf = (eTox == TOX_CONTENT) ? nsSwTOXElement::TOX_OUTLINELEVEL : nsSwTOXElement::TOX_MARK; sal_uInt16 nIndexCols = 1; const SwTOXType* pType = rDoc.GetTOXType( eTox, 0 ); SwForm aOrigForm(eTox); SwTOXBase* pBase = new SwTOXBase( pType, aOrigForm, nCreateOf, aEmptyStr ); pBase->SetProtected(maSectionManager.CurrentSectionIsProtected()); |
< 4. Switch case value "2"
3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 |
switch( eTox ){ case TOX_INDEX: { sal_uInt16 eOptions = nsSwTOIOptions::TOI_SAME_ENTRY | nsSwTOIOptions::TOI_CASE_SENSITIVE; // TOX_OUTLINELEVEL setzen wir genau dann, wenn // die Parameter \o in 1 bis 9 liegen // oder der Parameter \f existiert // oder GARKEINE Switches Parameter angegeben sind. long nRet; _ReadFieldParams aReadParam( rStr ); while( -1 != ( nRet = aReadParam.SkipToNextToken() )) { switch( nRet ) { case 'c': { xub_StrLen n = aReadParam.GoToTokenParam(); if( STRING_NOTFOUND != n ) { String sParams( aReadParam.GetResult() ); // if NO String just ignore the \c if( sParams.Len() ) { nIndexCols = static_cast<sal_uInt16>(sParams.ToInt32()); } } } break; case 'e': { xub_StrLen n = aReadParam.GoToTokenParam(); if( STRING_NOTFOUND != n ) // if NO String just ignore the \e { String sDelimiter( aReadParam.GetResult() ); SwForm aForm( pBase->GetTOXForm() ); // Attention: if TOX_CONTENT brave // GetFormMax() returns MAXLEVEL + 1 !! sal_uInt16 nEnd = aForm.GetFormMax()-1; for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel) { // Levels count from 1 // Level 0 is reserved for CAPTION // Delimiter statt Tabstop vor der Seitenzahl einsetzen, // falls es eine Seitenzahl gibt: FormTokenType ePrevType = TOKEN_END; FormTokenType eType; // -> #i21237# SwFormTokens aPattern = aForm.GetPattern(nLevel); SwFormTokens::iterator aIt = aPattern.begin(); do { eType = ++aIt == aPattern.end() ? TOKEN_END : aIt->eTokenType; if (eType == TOKEN_PAGE_NUMS) { if (TOKEN_TAB_STOP == ePrevType) { aIt--; if(0x09 == sDelimiter.GetChar(0)) aIt->eTabAlign = SVX_TAB_ADJUST_END; else { SwFormToken aToken(TOKEN_TEXT); aToken.sText = sDelimiter; *aIt = aToken; } aForm.SetPattern(nLevel, aPattern); } eType = TOKEN_END; } ePrevType = eType; } while (TOKEN_END != eType); // <- #i21237# } pBase->SetTOXForm( aForm ); } } break; case 'h': { eOptions |= nsSwTOIOptions::TOI_ALPHA_DELIMITTER; } break; } } pBase->SetOptions( eOptions ); } break; case TOX_CONTENT: { bool bIsHyperlink = false; bool bShowPage = true; // TOX_OUTLINELEVEL setzen wir genau dann, wenn // die Parameter \o in 1 bis 9 liegen // oder der Parameter \f existiert // oder GARKEINE Switches Parameter angegeben sind. sal_uInt16 eCreateFrom = 0; sal_uInt16 nMaxLevel = 0; long nRet; _ReadFieldParams aReadParam( rStr ); |
< 5. Condition "-1 != (nRet = aReadParam.SkipToNextToken())", taking true branch
< 9. Condition "-1 != (nRet = aReadParam.SkipToNextToken())", taking true branch
< 13. Condition "-1 != (nRet = aReadParam.SkipToNextToken())", taking true branch
< 18. Condition "-1 != (nRet = aReadParam.SkipToNextToken())", taking true branch
< 24. Condition "-1 != (nRet = aReadParam.SkipToNextToken())", taking true branch
< 30. Condition "-1 != (nRet = aReadParam.SkipToNextToken())", taking true branch
< 53. Condition "-1 != (nRet = aReadParam.SkipToNextToken())", taking false branch
3135 3136 |
while( -1 != ( nRet = aReadParam.SkipToNextToken() )) { |
< 6. Switch case value "104L"
< 10. Switch case value "104L"
< 14. Switch case value "97L"
< 19. Switch case value "111L"
< 25. Switch case value "111L"
< 31. Switch case value "110L"
3137 3138 3139 3140 |
switch( nRet ) { case 'h': bIsHyperlink = true; |
< 7. Breaking from switch
< 11. Breaking from switch
3141 3142 3143 |
break; case 'a': case 'c': |
< 15. Condition "'c' == nRet", taking false branch
3144 3145 3146 3147 |
lcl_toxMatchACSwitch(*this, rDoc, *pBase, aReadParam,
('c' == nRet)
? CAPTION_COMPLETE
: CAPTION_TEXT ); |
< 16. Breaking from switch
3148 3149 3150 3151 |
break; case 'o': { sal_uInt16 nVal; |
< 20. Condition "!aReadParam.GetTokenSttFromTo(NULL, &nVal, WW8ListManager::nMaxLevel)", taking true branch
< 26. Condition "!aReadParam.GetTokenSttFromTo(NULL, &nVal, WW8ListManager::nMaxLevel)", taking true branch
3152 3153 |
if( !aReadParam.GetTokenSttFromTo(0, &nVal, WW8ListManager::nMaxLevel) ) nVal = lcl_GetMaxValidWordTOCLevel(aOrigForm); |
< 21. Condition "nMaxLevel < nVal", taking true branch
< 27. Condition "nMaxLevel < nVal", taking true branch
3154 3155 3156 3157 |
if( nMaxLevel < nVal )
nMaxLevel = nVal;
eCreateFrom |= nsSwTOXElement::TOX_OUTLINELEVEL;
} |
< 22. Breaking from switch
< 28. Breaking from switch
3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 |
break; case 'f': eCreateFrom |= nsSwTOXElement::TOX_MARK; break; case 'l': { sal_uInt16 nVal; if( aReadParam.GetTokenSttFromTo(0, &nVal, WW8ListManager::nMaxLevel) ) { if( nMaxLevel < nVal ) nMaxLevel = nVal; eCreateFrom |= nsSwTOXElement::TOX_MARK; } } break; case 't': // paragraphs using special styles shall // provide the TOX's content lcl_toxMatchTSwitch(*this, *pBase, aReadParam); eCreateFrom |= nsSwTOXElement::TOX_TEMPLATE; break; case 'p': { xub_StrLen n = aReadParam.GoToTokenParam(); if( STRING_NOTFOUND != n ) // if NO String just ignore the \p { String sDelimiter( aReadParam.GetResult() ); SwForm aForm( pBase->GetTOXForm() ); // Attention: if TOX_CONTENT brave // GetFormMax() returns MAXLEVEL + 1 !! sal_uInt16 nEnd = aForm.GetFormMax()-1; for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel) { // Levels count from 1 // Level 0 is reserved for CAPTION // Delimiter statt Tabstop vor der Seitenzahl einsetzen, // falls es eine Seitenzahl gibt: FormTokenType ePrevType = TOKEN_END; FormTokenType eType; // -> #i21237# SwFormTokens aPattern = aForm.GetPattern(nLevel); SwFormTokens::iterator aIt = aPattern.begin(); do { eType = ++aIt == aPattern.end() ? TOKEN_END : aIt->eTokenType; if (eType == TOKEN_PAGE_NUMS) { if (TOKEN_TAB_STOP == ePrevType) { aIt--; SwFormToken aToken(TOKEN_TEXT); aToken.sText = sDelimiter; *aIt = aToken; aForm.SetPattern(nLevel, aPattern); } eType = TOKEN_END; } ePrevType = eType; } while( TOKEN_END != eType ); // <- #i21237# } pBase->SetTOXForm( aForm ); } } break; case 'n': // don't print page numbers { // read START and END param bShowPage = false; sal_uInt16 nStart, nEnd; |
< 32. Condition "!aReadParam.GetTokenSttFromTo(&nStart, &nEnd, WW8ListManager::nMaxLevel)", taking true branch
3238 3239 3240 3241 3242 3243 3244 3245 |
if( !aReadParam.GetTokenSttFromTo( &nStart, &nEnd, WW8ListManager::nMaxLevel ) ) { nStart = 1; nEnd = aOrigForm.GetFormMax()-1; } // remove page numbers from this levels SwForm aForm( pBase->GetTOXForm() ); |
< 33. Condition "aForm.GetFormMax() <= nEnd", taking true branch
3246 3247 |
if (aForm.GetFormMax() <= nEnd) nEnd = aForm.GetFormMax()-1; |
< 34. Condition "nLevel <= nEnd", taking true branch
< 39. Condition "nLevel <= nEnd", taking true branch
< 44. Condition "nLevel <= nEnd", taking true branch
< 50. Condition "nLevel <= nEnd", taking false branch
3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 |
for ( sal_uInt16 nLevel = nStart; nLevel <= nEnd; ++nLevel ) { // Levels count from 1 // Level 0 is reserved for CAPTION // Seitenzahl und ggfs. davorstehenden Tabstop // entfernen: FormTokenType eType; // -> #i21237# SwFormTokens aPattern = aForm.GetPattern(nLevel); SwFormTokens::iterator aIt = aPattern.begin(); do { |
< 35. Condition "++aIt == aPattern.end()", taking true branch
< 40. Condition "++aIt == aPattern.end()", taking true branch
< 45. Condition "++aIt == aPattern.end()", taking false branch
3264 |
eType = ++aIt == aPattern.end() ? TOKEN_END : aIt->eTokenType; |
< 36. Condition "eType == TOKEN_PAGE_NUMS", taking false branch
< 41. Condition "eType == TOKEN_PAGE_NUMS", taking false branch
< 46. Condition "eType == TOKEN_PAGE_NUMS", taking true branch
3266 3267 3268 3269 |
if (eType == TOKEN_PAGE_NUMS)
{
aIt = aPattern.erase(aIt);
aIt--; |
< 47. Condition "TOKEN_TAB_STOP == aIt->eTokenType", taking true branch
3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 |
if (
TOKEN_TAB_STOP ==
aIt->eTokenType
)
{
aPattern.erase(aIt);
aForm.SetPattern(nLevel, aPattern);
}
eType = TOKEN_END;
}
} |
< 37. Condition "TOKEN_END != eType", taking false branch
< 42. Condition "TOKEN_END != eType", taking false branch
< 48. Condition "TOKEN_END != eType", taking false branch
3281 3282 |
while (TOKEN_END != eType); // <- #i21237# |
< 38. Jumping back to the beginning of the loop
< 43. Jumping back to the beginning of the loop
< 49. Jumping back to the beginning of the loop
3283 3284 3285 |
} pBase->SetTOXForm( aForm ); } |
< 51. Breaking from switch
3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 |
break; /* // the following switches are not (yet) supported // by good old StarWriter: case 'b': case 's': case 'd': break; */ } |
< 8. Jumping back to the beginning of the loop
< 12. Jumping back to the beginning of the loop
< 17. Jumping back to the beginning of the loop
< 23. Jumping back to the beginning of the loop
< 29. Jumping back to the beginning of the loop
< 52. Jumping back to the beginning of the loop
3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 |
} // For loading the expression of TOC field, we need to mapping its parameters to TOX entries tokens // also include the hyperlinks and page references SwFormToken aLinkStart(TOKEN_LINK_START); SwFormToken aLinkEnd(TOKEN_LINK_END); aLinkStart.sCharStyleName = String::CreateFromAscii("Index Link"); aLinkEnd.sCharStyleName = String::CreateFromAscii("Index Link"); SwForm aForm(pBase->GetTOXForm()); sal_uInt16 nEnd = aForm.GetFormMax()-1; |
< 54. Condition "nLevel <= nEnd", taking true branch
< 58. Condition "nLevel <= nEnd", taking true branch
< 62. Condition "nLevel <= nEnd", taking false branch
3308 3309 3310 |
for(sal_uInt16 nLevel = 1; nLevel <= nEnd; ++nLevel) { SwFormTokens aPattern = aForm.GetPattern(nLevel); |
< 55. Condition "bIsHyperlink", taking true branch
< 59. Condition "bIsHyperlink", taking true branch
3311 3312 3313 |
if ( bIsHyperlink )
{
aPattern.insert(aPattern.begin(), aLinkStart); |
< 56. Falling through to end of if statement
< 60. Falling through to end of if statement
3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 |
} else if ( bShowPage ) { for (SwFormTokens::iterator aItr = aPattern.begin();aItr!= aPattern.end();aItr++) { if (aItr->eTokenType == TOKEN_PAGE_NUMS) { aPattern.insert(aItr,aLinkStart); break; } } } aPattern.push_back(aLinkEnd); aForm.SetPattern(nLevel, aPattern); |
< 57. Jumping back to the beginning of the loop
< 61. Jumping back to the beginning of the loop
3328 3329 |
} pBase->SetTOXForm(aForm); |
< 63. Condition "!nMaxLevel", taking false branch
3331 3332 3333 3334 3335 |
if (!nMaxLevel) nMaxLevel = WW8ListManager::nMaxLevel; pBase->SetLevel(nMaxLevel); const TOXTypes eType = pBase->GetTOXType()->GetType(); |
< 64. Switch case value "2"
3336 3337 3338 3339 3340 3341 3342 |
switch( eType ) { case TOX_CONTENT: { //If we would be created from outlines, either explictly or by default //then see if we need extra styles added to the outlines sal_uInt16 eEffectivelyFrom = eCreateFrom ? eCreateFrom : nsSwTOXElement::TOX_OUTLINELEVEL; |
< 65. Condition "eEffectivelyFrom & 2 /* nsSwTOXElement::TOX_OUTLINELEVEL */", taking true branch
3343 3344 3345 3346 3347 3348 3349 |
if (eEffectivelyFrom & nsSwTOXElement::TOX_OUTLINELEVEL) { // #i19683# Insert a text token " " between the number and entry token. // In an ideal world we could handle the tab stop between the number and // the entry correctly, but I currently have no clue how to obtain the tab stop position. // It is _not_ set at the paragraph style. SwForm* pForm = 0; |
< 66. Condition "nI < this->nColls", taking true branch
< 75. Condition "nI < this->nColls", taking false branch
3350 3351 3352 |
for (sal_uInt16 nI = 0; nI < nColls; ++nI) { const SwWW8StyInf& rSI = pCollA[nI]; |
< 67. Condition "rSI->IsOutlineNumbered()", taking true branch
3353 3354 3355 3356 |
if (rSI.IsOutlineNumbered()) { sal_uInt16 nStyleLevel = rSI.mnWW8OutlineLevel; const SwNumFmt& rFmt = rSI.GetOutlineNumrule()->Get( nStyleLevel ); |
< 68. Condition "SVX_NUM_NUMBER_NONE != rFmt->GetNumberingType()", taking true branch
3357 3358 3359 |
if ( SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType() )
{
++nStyleLevel;
|
< 69. Condition "!pForm", taking true branch
3361 |
if ( !pForm ) |
<< 70. Storage is returned from allocation function "operator new(size_t)".
<< 71. Assigning: "pForm" = storage returned from "new SwForm(pBase->GetTOXForm())".
3362 |
pForm = new SwForm( pBase->GetTOXForm() ); |
<< 72. Resource "pForm" is not freed or pointed-to in function "SwForm::GetPattern(sal_uInt16) const".
3364 3365 3366 3367 |
SwFormTokens aPattern = pForm->GetPattern(nStyleLevel); SwFormTokens::iterator aIt = find_if(aPattern.begin(), aPattern.end(), SwFormTokenEqualToFormTokenType(TOKEN_ENTRY_NO)); |
< 73. Condition "aIt != aPattern.end()", taking false branch
3369 3370 3371 3372 3373 3374 3375 3376 3377 |
if ( aIt != aPattern.end() ) { SwFormToken aNumberEntrySeparator( TOKEN_TEXT ); aNumberEntrySeparator.sText = String::CreateFromAscii(" "); aPattern.insert( ++aIt, aNumberEntrySeparator ); pForm->SetPattern( nStyleLevel, aPattern ); } } } |
< 74. Jumping back to the beginning of the loop
3378 |
} |
< 76. Condition "pForm", taking true branch
3379 |
if ( pForm ) |
<< 77. Resource "pForm" is not freed or pointed-to in function "SwTOXBase::SetTOXForm(SwForm const &)".
3380 3381 |
pBase->SetTOXForm( *pForm );
// <-- |
<<< CID 705753: Resource leaks RESOURCE_LEAK <<< 78. Variable "pForm" going out of scope leaks the storage it points to.
3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 |
} if (eCreateFrom) pBase->SetCreate(eCreateFrom); EnsureMaxLevelForTemplates(*pBase); } break; case TOX_ILLUSTRATIONS: { if( !eCreateFrom ) eCreateFrom = nsSwTOXElement::TOX_SEQUENCE; pBase->SetCreate( eCreateFrom ); /* #91214# We don't know until here if we are an illustration or not, and so have being used a TOX_CONTENT so far which has 10 levels, while TOX has only two, this level is set only in the constructor of SwForm, so create a new one and copy over anything that could be set in the old one, and remove entries from the pattern which do not apply to illustration indices */ SwForm aOldForm( pBase->GetTOXForm() ); SwForm aForm( eType ); sal_uInt16 nEnd = aForm.GetFormMax()-1; |
70. alloc_fn | ww8par5.cxx:3362 | |
71. var_assign | ww8par5.cxx:3362 | |
72. noescape | ww8par5.cxx:3364 | |
77. noescape | ww8par5.cxx:3380 | |
78. leaked_storage | ww8par5.cxx:3382 |