[Libreoffice] [PUSHED, partial] Re: [PATCH] RTL_CONSTASCII_USTRINGPARAM for libs-core/sfx2

Caolán McNamara caolanm at redhat.com
Mon Nov 22 04:46:41 PST 2010


On Sun, 2010-11-21 at 16:44 +0100, Julien Nabet wrote:
> Hello,
> 
> Here's a patch for libs-core/sfx2

Watch out here, see...

sKey  = ::rtl::OUString::createFromAscii(JOBCFG_ROOT);

JOBCFG_ROOT is actually...

static const sal_Char* JOBCFG_ROOT = "foo"

so JOBCFG_ROOT is a pointer, not a string literal, or an array.
which means that

::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(JOBCFG_ROOT));

would expand to something like

::rtl::OUString(JOBCFG, 8, US_ASCII);

(of 4 on a 32bit system, i.e. sizeof(JOBCFG) operates on a pointer) and
not the expected

::rtl::OUString("foo", 3, US_ASCII);

In contrast, in sfx2

static ::rtl::OUString
content(::rtl::OUString::createFromAscii(s_content));

s_content here is an array, not a pointer.

const char s_content [] = "content.xml";

so this one can be converted to 

static ::rtl::OUString content(RTL_CONSTASCII_USTRINGPARAM(s_content));

I have some magic on a feature branch to catch this sort of error if it
happens, but it needs c++0x to be completely correct to roll-out, I
should work on that as something of a priority.

C.



More information about the LibreOffice mailing list