[vorbis-dev] Nonportable use of strdup()

Dimitry Andric dim at xs4all.nl
Tue Dec 18 09:35:37 PST 2001


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2001-12-18 at 17:23:48 Sam Lantinga wrote:

SL> Hey, I ran across this while building vorbis on the Mac:
SL> In libvorbis RC2, file info.c, line 65, there's a call to strdup().
SL> strdup() isn't portable, and it looks like the code should use the
SL> internal memory functions to create the memory for the string anyway.

trdup() might not be portable, but almost every compiler in the world
has it, except MetroWerks CodeWarrior, both on Windows and Mac. And
even they have it somewhere, only they call it _strdup, for reasons
unknown to me.

Please try the attached patch for the vorbis component. This contains
a define for strdup (it makes sense to use the compiler intrinsic
function instead of a self-baked version, because it can be better
optimized), and a fix for the signedness problems in struct
vorbis_look_psy (which causes CW6 & 7 to complain).

Note that this is only for RC2, this patch might not work for the
head revision. But you shouldn't be using that for any production work
anyway. :) Please contact me if you need a patch for the main branch.

SL> Actually, on further inspection, it looks like the memory for the
SL> user comments is never actually freed.

That's another problem of course, can you please point out where, or
send a (unified) diff?

Cheers,
- --
Dimitry Andric <dim at xs4all.nl>
PGP Key: http://www.xs4all.nl/~dim/dim.asc
Fingerprint: 7AB462D2CE35FC6D42394FCDB05EA30A2E2096A3
Lbh ner abj va ivbyngvba bs gur QZPN

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5i
Comment: http://www.gn.apc.org/duncan/stoa_cover.htm

iQA/AwUBPB9wX7BeowouIJajEQKTtACg+NZRmLNP3vXfSte3QT8F4SmABTQAoJI/
RVanDTOjeYV+W3xUStV14rwj
=Ju5V
-----END PGP SIGNATURE-----

<HR NOSHADE>
<UL>
<LI>application/octet-stream attachment: vorbis.patch
</UL>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vorbis.patch
Type: application/octet-stream
Size: 895 bytes
Desc: not available
Url : http://lists.xiph.org/pipermail/vorbis-dev/attachments/20011218/c22bd229/vorbis-0001.obj


More information about the Vorbis-dev mailing list