[sword-devel] Accidental removal of code in SVN 3754?

Troy A. Griffitts scribe at crosswire.org
Mon Oct 19 09:42:43 EDT 2020


Hi Jaak,

I just did an:

svn diff -r3753:3754

and don't see this change as you show it but do see the same result of 
your patch and the patch I get from the svn diff.  This does leave a 
*len = slen, which also seems to me dangerous.  I also am having a bit 
of trouble following this code, but certainly a check of len before 
setting *len seems appropriate.  I will commit it with the patch from 
your next email.


On 10/19/20 2:46 PM, Jaak Ristioja wrote:
> Hi!
>
> It seems that SVN 3754 might accidentally have removed a line of code 
> together with the preceding comment in SWCompress::setUncompressedBuf():
>
>         if (!buf) {
>                 buf = (char *)calloc(1,1); // be sure we at least 
> allocate an empty buf for return;
>                 direct = 1;
>                 decode();
> -//             slen = strlen(buf);
> -               if (len)
>                 *len = slen;
>         }
>
> To be honest I must say it is difficult to understand this code, but 
> I'm a bit puzzled about this change nevertheless. As far as I can 
> tell, the len pointer might be null, and this check would prevent it 
> from being dereferenced. Or does the API have a hidden contract that 
> if !ibuf then len!=nullptr?
>
>
> Best regards,
> J
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page


More information about the sword-devel mailing list