Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

On Sun, Jan 13, 2013 at 9:01 PM, julien2412 <serval2412@yahoo.fr> wrote:
Hello,

Taking a look at this cppcheck report:
dlc/source/idlccompile.cxx
198     nullPointer     error   Possible null pointer dereference: source - otherwise
it is redundant to check it against null.

Looks like a false-positive of cppcheck. source is checked against
null to determine whether to take stdin or source file as data source,
then at lines 198 & 207 pSource file handle is closed only if it had
been opened (which is done only for source==0). I don't see any way
there could be a null pointer dereference.

I don't understand the function "sal_Bool copyFile(const OString* source,
const OString& target)", above all this part:
    192     while ( !feof(pSource) )
    193     {
    194         if ( (readSize = fread(pBuffer, 1, totalSize, pSource)) > 0
&& !ferror(pSource) )
    195         {
    196             if ( (fwrite(pBuffer, 1, readSize, pTarget)) != readSize
|| ferror(pTarget) )
    197             {
    198                 if (source != 0) {
    199                     fclose(pSource);
    200                 }
    201                 fclose(pTarget);
    202                 return sal_False;
    203             }
    204         }
    205     }
see
http://opengrok.libreoffice.org/xref/core/idlc/source/idlccompile.cxx#173
Isn't it overcomplicated? Why reading a file 1 per 1 byte for example?

It's not reading 1 byte at a time. It's reading totalSize bytes at a
time, getting readSize with 1 byte granularity.


Julien



--
View this message in context: 
http://nabble.documentfoundation.org/About-idlc-source-idlccompile-cxx-tp4028889.html
Sent from the Dev mailing list archive at Nabble.com.
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Regards,
Ruslan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.