mirror of
				https://github.com/taglib/taglib.git
				synced 2025-11-03 16:26:18 -05:00 
			
		
		
		
	Don't try to read the properties from the bytevector if it's smaller than
the required size; in this case empty. Also some minor nitpicks along the way. CCMAIL:83898-done@bugs.kde.org git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@323360 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
		@ -102,6 +102,11 @@ int FLAC::Properties::channels() const
 | 
			
		||||
 | 
			
		||||
void FLAC::Properties::read()
 | 
			
		||||
{
 | 
			
		||||
  if(d->data.size() < 18) {
 | 
			
		||||
    debug("FLAC::Properties::read() - FLAC properties must contain at least 18 bytes.");
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  int pos = 0;
 | 
			
		||||
 | 
			
		||||
  // Minimum block size (in samples)
 | 
			
		||||
@ -121,13 +126,13 @@ void FLAC::Properties::read()
 | 
			
		||||
  d->channels = ((flags >> 9) & 7) + 1;
 | 
			
		||||
  d->sampleWidth = ((flags >> 4) & 31) + 1;
 | 
			
		||||
 | 
			
		||||
  // The last 4 bit are the most significant 4 bits for the 36bit
 | 
			
		||||
  // streamlength in samples. (Audio files measured in days)
 | 
			
		||||
  // The last 4 bits are the most significant 4 bits for the 36 bit
 | 
			
		||||
  // stream length in samples. (Audio files measured in days)
 | 
			
		||||
 | 
			
		||||
  uint highlength = (((flags & 0xf) << 28) / d->sampleRate) << 4;
 | 
			
		||||
  uint highLength = (((flags & 0xf) << 28) / d->sampleRate) << 4;
 | 
			
		||||
  pos += 4;
 | 
			
		||||
 | 
			
		||||
  d->length = (d->data.mid(pos, 4).toUInt(true)) / d->sampleRate + highlength;
 | 
			
		||||
  d->length = (d->data.mid(pos, 4).toUInt(true)) / d->sampleRate + highLength;
 | 
			
		||||
  pos += 4;
 | 
			
		||||
 | 
			
		||||
  // Uncompressed bitrate:
 | 
			
		||||
@ -136,8 +141,8 @@ void FLAC::Properties::read()
 | 
			
		||||
  
 | 
			
		||||
  // Real bitrate:
 | 
			
		||||
  
 | 
			
		||||
  if (d->length)
 | 
			
		||||
    d->bitrate = ((d->streamLength*8L) / d->length)/1000;
 | 
			
		||||
  if(d->length)
 | 
			
		||||
    d->bitrate = ((d->streamLength * 8L) / d->length) / 1000;
 | 
			
		||||
  else
 | 
			
		||||
    d->bitrate = 0;
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
@ -44,13 +44,15 @@ namespace TagLib {
 | 
			
		||||
       * Create an instance of FLAC::Properties with the data read from the
 | 
			
		||||
       * ByteVector \a data.
 | 
			
		||||
       */
 | 
			
		||||
       // BIC: switch to const reference
 | 
			
		||||
      Properties(ByteVector data, long streamLength, ReadStyle style = Average);
 | 
			
		||||
 | 
			
		||||
      /*!
 | 
			
		||||
       * Create an instance of FLAC::Properties with the data read from the
 | 
			
		||||
       * FLAC::File \a file.
 | 
			
		||||
       */
 | 
			
		||||
      Properties(File *file, ReadStyle style = Average); // BIC: remove
 | 
			
		||||
       // BIC: remove
 | 
			
		||||
      Properties(File *file, ReadStyle style = Average);
 | 
			
		||||
 | 
			
		||||
      /*!
 | 
			
		||||
       * Destroys this FLAC::Properties instance.
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user