msdmo: Array parameter is passed to function as pointer so loses size information

Robert Shearman rob at
Thu Apr 10 06:08:48 CDT 2008

Andrew Talbot wrote:
> Robert Shearman wrote:
>> This is incorrect. count is the size in bytes of the buffer passed in
>> (szName) and so should be sizeof(szName) not
>> sizeof(szName)/sizeof(szName[0]) (i.e. 80).
> Are you sure? MSDN says "szName: Array of 80 Unicode characters that
> receives the name of the DMO".

It doesn't matter what MSDN says about szName, RegQueryValueExW still 
takes the size in bytes, not characters. I.e. count should be set to 

> But, in any case, when arrays
> are passed as arguments to functions they are converted to pointers, so
> sizeof(szName) would represent the size of a pointer to the array, not the
> size of the array itself.

I didn't realise this before but the attached test program prints:
$ ./atest
sizeof(array) = 4
So you are right. Still, my point stands that the code is still passing 
in a smaller size than the size of the buffer and so is not correct.

Rob Shearman

-------------- next part --------------
A non-text attachment was scrubbed...
Name: atest.c
Type: text/x-csrc
Size: 166 bytes
Desc: not available
Url : 

More information about the wine-devel mailing list