Bug 65551

Summary: cppcheck report
Product: poppler Reporter: Julien Nabet <serval2412>
Component: utilsAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Complete cppcheck report
Fix Prefer ++ op
Patch for mismatching alloc/dealloc
patch for a memory leak

Description Julien Nabet 2013-06-08 21:34:53 UTC
Created attachment 80536 [details]
Complete cppcheck report

Hello,

I launched cppcheck git updated today on poppler git updated today.
There are false positives but some may interest you, eg:

[poppler/UTF.cc:104]: (error) Mismatching allocation and deallocation: utf16
[qt4/src/poppler-private.h:90]: (error) Mismatching allocation and deallocation: fileName
[splash/Splash.cc:3802] -> [splash/Splash.cc:3802]: (style) Same expression on both sides of '||'
[utils/HtmlOutputDev.cc:1704]: (error) Memory leak: str
[poppler/Annot.cc:3161] -> [poppler/Annot.cc:3159]: (style) Found duplicate branches for 'if' and 'else'.
[poppler/Annot.cc:3859] -> [poppler/Annot.cc:3857]: (style) Found duplicate branches for 'if' and 'else'.
etc.

Julien
PS : sorry, I selected "utils" for component but I launched cppcheck on the whole project.
Comment 1 Julien Nabet 2013-06-08 21:43:08 UTC
Created attachment 80537 [details] [review]
Fix Prefer ++ op

Here's a patch for "Prefer prefix ++/-- operators for non-primitive types"
Comment 2 Julien Nabet 2013-06-08 22:31:14 UTC
Created attachment 80538 [details] [review]
Patch for mismatching alloc/dealloc

Here's a patch for:
[poppler/UTF.cc:104]: (error) Mismatching allocation and deallocation: utf16
[qt4/src/poppler-private.h:90]: (error) Mismatching allocation and deallocation: fileName
Comment 3 Julien Nabet 2013-06-08 22:46:40 UTC
Created attachment 80539 [details] [review]
patch for a memory leak
Comment 4 Albert Astals Cid 2013-06-09 10:15:51 UTC
I've commited the patches you've attached the other style fixes you mention look "ok" to be honest.

Thanks!
Comment 5 Julien Nabet 2013-06-09 10:37:39 UTC
Thank you Albert for your quick feedback.

However, there are still some like these:
[splash/Splash.cc:3802] -> [splash/Splash.cc:3802]: (style) Same expression on both sides of '||'
[utils/HtmlOutputDev.cc:1704]: (error) Memory leak: str
[poppler/Annot.cc:3161] -> [poppler/Annot.cc:3159]: (style) Found duplicate branches for 'if' and 'else'.
[poppler/Annot.cc:3859] -> [poppler/Annot.cc:3857]: (style) Found duplicate branches for 'if' and 'else'.
which may not only style problem. (on the contrary of Reduce scope, casting, etc). 

I'll try to send other patches in the next days for style. (except casts because I never know when to use dynamic cast vs static cast for eg)
Comment 6 Albert Astals Cid 2013-06-09 10:46:56 UTC
splash/Splash.cc:3802 i checked and yes, given the value of yp the second part of the if is not needed, but helps "mentally"

utils/HtmlOutputDev.cc:1704 you fixed in "patch for a memory leak"

poppler/Annot.cc:3161 looks like a false positive to me

poppler/Annot.cc:3859 is an unimplemented feature
Comment 7 Julien Nabet 2013-06-09 10:59:18 UTC
Oups, sorry for memleak, I thought about removing this after copy paste but finally forgot :-)
Ok for the rest.
Comment 8 Julien Nabet 2013-06-30 09:10:14 UTC
Albert: I'm running a new cppcheck scan, just for my information, is "hb-old" sub directory really used or should it be removed?
Comment 9 Julien Nabet 2013-06-30 09:11:00 UTC
oups sorry for my last comment

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.