You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Lee Doron (JIRA)" <xe...@xml.apache.org> on 2012/06/06 11:01:27 UTC

[jira] [Commented] (XERCESC-1986) Fix for MacOSUnicodeConverter::CopyCStringToPascal

    [ https://issues.apache.org/jira/browse/XERCESC-1986?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13290034#comment-13290034 ] 

Lee Doron commented on XERCESC-1986:
------------------------------------

Agreed. Consider the following test code -- when you run it (try http://codepad.org/ZsmOvOAZ for convenience), you get "4, 256, 256". The value returned into "len" is 4 because the array type decayed into a pointer when used as a parameter (see http://stackoverflow.com/a/1570616/768820 for details):

#include <stdio.h>

typedef unsigned char s255[256];

int siz(s255 pas)
{
    return sizeof(pas);
}

int main()
{
    s255 pas2;
    int len = siz(pas2);
    printf("%d, %d, %d\n", len, sizeof(pas2), sizeof(s255));
}

                
> Fix for MacOSUnicodeConverter::CopyCStringToPascal
> --------------------------------------------------
>
>                 Key: XERCESC-1986
>                 URL: https://issues.apache.org/jira/browse/XERCESC-1986
>             Project: Xerces-C++
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 3.1.1
>         Environment: Mac OS X 10.6 and 10.7
>            Reporter: benoit.blaquiere
>              Labels: patch
>
> sizeof(pas) must be replace by sizeof(Str255), because sizeof(pas) returns sizeof(unsigned char *) and not sizeof(unsigned char[256]) as desired.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org