Skip to content

ASFPicture fix warning - #10

Merged
lalinsky merged 1 commit into
taglib:masterfrom
asergunov:ASFPicture_warning_fix
Jul 28, 2011
Merged

lalinsky merged 1 commit into
taglib:masterfrom
asergunov:ASFPicture_warning_fix

Conversation

@asergunov

Copy link
Copy Markdown
Contributor

class/struct thing

class/struct thing

Signed-off-by: Anton Sergunov <[email protected]>
@lalinsky

lalinsky commented Jul 1, 2011

Copy link
Copy Markdown
Member

What was the warning?

@asergunov

Copy link
Copy Markdown
Contributor Author

"struct" in .h
"class" in .cpp

@sbooth

sbooth commented Jul 1, 2011

Copy link
Copy Markdown
Contributor

This seems odd to me since in C++ structs are just classes with everything public. It seems like the change doesn't change anything.

@lalinsky

lalinsky commented Jul 1, 2011

Copy link
Copy Markdown
Member

Yeah, that's why I asked about the warning. I'd like to know which compiler does produce a warning in this situation.

@asergunov

Copy link
Copy Markdown
Contributor Author

It's cl.exe (MS Visual studio 2008)

cl.exe says:

.\ogg\vorbis\vorbisproperties.cpp(176) : warning C4244: '=' : conversion from '__int64' to 'int', possible loss of data
.\toolkit\unicode.cpp(158) : warning C4244: '=' : conversion from 'Unicode::UTF32' to 'Unicode::UTF8', possible loss of data
.\toolkit\unicode.cpp(256) : warning C4244: '=' : conversion from 'Unicode::UTF32' to 'Unicode::UTF16', possible loss of data
.\toolkit\unicode.cpp(273) : warning C4244: '=' : conversion from 'unsigned long' to 'Unicode::UTF16', possible loss of data
.\toolkit\tstring.cpp(238) : warning C4390: ';' : empty controlled statement found; is this the intent?
.\toolkit\tstring.cpp(261) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\string.h(74) : see declaration of 'strcpy'
.\toolkit\tstring.cpp(760) : warning C4390: ';' : empty controlled statement found; is this the intent?
.\toolkit\tfilestream.cpp(95) : warning C4996: '_wfopen': This function or variable may be unsafe. Consider using _wfopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(594) : see declaration of '_wfopen'
.\toolkit\tfilestream.cpp(97) : warning C4996: '_wfopen': This function or variable may be unsafe. Consider using _wfopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(594) : see declaration of '_wfopen'
.\toolkit\tfilestream.cpp(102) : warning C4996: '_wfopen': This function or variable may be unsafe. Consider using _wfopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(594) : see declaration of '_wfopen'
.\toolkit\tfilestream.cpp(113) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(237) : see declaration of 'fopen'
.\toolkit\tfilestream.cpp(115) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(237) : see declaration of 'fopen'
.\toolkit\tfilestream.cpp(120) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(237) : see declaration of 'fopen'
.\toolkit\tfilestream.cpp(382) : warning C4996: 'fileno': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fileno. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\stdio.h(722) : see declaration of 'fileno'
.\toolkit\tfile.cpp(324) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(303) : see declaration of 'access'
.\toolkit\tfile.cpp(329) : warning C4996: 'access': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _access. See online help for details.
c:\Program Files\Microsoft Visual Studio 9.0\VC\include\io.h(303) : see declaration of 'access'
.\toolkit\tbytevectorstream.cpp(84) : warning C4018: '>' : signed/unsigned mismatch
.\ogg\flac\oggflacfile.cpp(269) : warning C4390: ';' : empty controlled statement found; is this the intent?
.\mpeg\mpegproperties.cpp(224) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
.\mpeg\id3v2\id3v2tag.cpp(556) : warning C4390: ';' : empty controlled statement found; is this the intent?
.\flac\flacfile.cpp(210) : warning C4309: '=' : truncation of constant value
.\asf\asfpicture.cpp(38) : warning C4099: 'TagLib::ASF::Picture::PicturePriavte' : type name first seen using 'struct' now seen using 'class'
[path]\taglib\asf\asfpicture.h(211) : see declaration of 'TagLib::ASF::Picture::PicturePriavte'
.\asf\asffile.cpp(343) : warning C4244: 'argument' : conversion from '__int64' to 'unsigned int', possible loss of data
.\asf\asffile.cpp(530) : warning C4244: 'argument' : conversion from 'unsigned __int64' to 'TagLib::ulong', possible loss of data
.\riff\aiff\aiffproperties.cpp(157) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
.\riff\aiff\aiffproperties.cpp(158) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data

@lalinsky
lalinsky merged commit 68c6a7d into taglib:master Jul 28, 2011
ufleisch pushed a commit that referenced this pull request Aug 15, 2026
DSF::Properties::read computes

    d->length = d->samplingFrequency > 0
        ? static_cast<unsigned int>(static_cast<double>(d->sampleCount)
                                    * 1000.0 / d->samplingFrequency + 0.5)
        : 0;

sampleCount is a long long taken straight from the file and
samplingFrequency is an unsigned int from the file, so the millisecond
count can land well outside unsigned int. Converting a floating point
value the destination type cannot represent is undefined:

  taglib/dsf/dsfproperties.cpp:132:35: runtime error: 8.41595e+09 is
  outside the range of representable values of type 'unsigned int'
    #0 TagLib::DSF::Properties::read(TagLib::ByteVector const&)
    #1 TagLib::DSF::Properties::Properties(...)
    #10 TagLib::FileRef::FileRef(char const*, bool, ...)

A negative sampleCount converts just as badly, so guard that too.

Report an unknown length instead of converting, matching what a zero
sampling frequency already does. Nothing changes for a valid file:
tests/data/empty10ms.dsf reads lengthMs=10 bitrate=5645 rate=2822400
ch=2 both before and after.

Found by mutating the files in tests/data and running them through a
parse, read properties and save round trip under UBSan.

Assisted-By: Claude Code (Claude Opus 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants