About idlc/source/idlccompile.cxx

Ruslan Kabatsayev b7.10110111 at gmail.com
Sun Jan 13 11:06:50 PST 2013


Hi,

On Sun, Jan 13, 2013 at 9:01 PM, julien2412 <serval2412 at 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 at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice

Regards,
Ruslan


More information about the LibreOffice mailing list