]> granicus.if.org Git - taglib/commitdiff
Avoid the risk of subtracting between signed and unsigned types.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 21 Dec 2015 02:44:25 +0000 (11:44 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Mon, 21 Dec 2015 02:44:25 +0000 (11:44 +0900)
taglib/ape/apefile.cpp
taglib/flac/flacfile.cpp
taglib/mpc/mpcfile.cpp
taglib/mpeg/mpegfile.cpp
taglib/trueaudio/trueaudiofile.cpp
taglib/wavpack/wavpackfile.cpp

index c0e32c33d4ac212f7d7245c879f531b5f19d8eb2..9f298aaf4ca1d8dad6a03670d7138b4e02026d6c 100644 (file)
@@ -70,13 +70,13 @@ public:
   }
 
   long APELocation;
-  unsigned int APESize;
+  long APESize;
 
   long ID3v1Location;
 
   ID3v2::Header *ID3v2Header;
   long ID3v2Location;
-  unsigned int ID3v2Size;
+  long ID3v2Size;
 
   TagUnion tag;
 
@@ -186,7 +186,7 @@ bool APE::File::save()
     insert(data, d->APELocation, d->APESize);
 
     if(d->ID3v1Location >= 0)
-      d->ID3v1Location += (data.size() - d->APESize);
+      d->ID3v1Location += (static_cast<long>(data.size()) - d->APESize);
 
     d->APESize = data.size();
   }
index 2e58e84803d3fbec96efcd3f7845c98638bd1a8e..fb7418d1ce68b77139ea8ae83585eca247dd351b 100644 (file)
@@ -80,7 +80,7 @@ public:
 
   const ID3v2::FrameFactory *ID3v2FrameFactory;
   long ID3v2Location;
-  unsigned int ID3v2OriginalSize;
+  long ID3v2OriginalSize;
 
   long ID3v1Location;
 
@@ -226,10 +226,10 @@ bool FLAC::File::save()
 
   insert(data, d->flacStart, originalLength);
 
-  d->streamStart += (data.size() - originalLength);
+  d->streamStart += (static_cast<long>(data.size()) - originalLength);
 
   if(d->ID3v1Location >= 0)
-    d->ID3v1Location += (data.size() - originalLength);
+    d->ID3v1Location += (static_cast<long>(data.size()) - originalLength);
 
   // Update ID3 tags
 
@@ -243,11 +243,11 @@ bool FLAC::File::save()
     data = ID3v2Tag()->render();
     insert(data, d->ID3v2Location, d->ID3v2OriginalSize);
 
-    d->flacStart   += (data.size() - d->ID3v2OriginalSize);
-    d->streamStart += (data.size() - d->ID3v2OriginalSize);
+    d->flacStart   += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
+    d->streamStart += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
 
     if(d->ID3v1Location >= 0)
-      d->ID3v1Location += (data.size() - d->ID3v2OriginalSize);
+      d->ID3v1Location += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
 
     d->ID3v2OriginalSize = data.size();
   }
index b586bbf6e81e2531b7f585442b7cc0262dfd4673..daf24c8fb7be565c20cb9e944ad1b367b763aa78 100644 (file)
@@ -62,13 +62,13 @@ public:
   }
 
   long APELocation;
-  unsigned int APESize;
+  long APESize;
 
   long ID3v1Location;
 
   ID3v2::Header *ID3v2Header;
   long ID3v2Location;
-  unsigned int ID3v2Size;
+  long ID3v2Size;
 
   TagUnion tag;
 
@@ -193,7 +193,7 @@ bool MPC::File::save()
     insert(data, d->APELocation, d->APESize);
 
     if(d->ID3v1Location >= 0)
-      d->ID3v1Location += (data.size() - d->APESize);
+      d->ID3v1Location += (static_cast<long>(data.size()) - d->APESize);
 
     d->APESize = data.size();
   }
index e1910c2d0000d1126a964005e3a20ca68be66e36..4fc3533f39be546377bc5e482caee3d576060cf0 100644 (file)
@@ -82,10 +82,10 @@ public:
   const ID3v2::FrameFactory *ID3v2FrameFactory;
 
   long ID3v2Location;
-  unsigned int ID3v2OriginalSize;
+  long ID3v2OriginalSize;
 
   long APELocation;
-  unsigned int APEOriginalSize;
+  long APEOriginalSize;
 
   long ID3v1Location;
 
@@ -274,7 +274,7 @@ bool MPEG::File::save(int tags, bool stripOthers, int id3v2Version, bool duplica
       insert(data, d->APELocation, d->APEOriginalSize);
 
       if(d->ID3v1Location >= 0)
-        d->ID3v1Location += (data.size() - d->APEOriginalSize);
+        d->ID3v1Location += (static_cast<long>(data.size()) - d->APEOriginalSize);
 
       d->APEOriginalSize = data.size();
     }
index 27dc606d885c3346f73c3eecf4a3896cb06aecf9..fc123ba34eb94007b1ce0218a5c99abbc46c3f32 100644 (file)
@@ -64,7 +64,7 @@ public:
 
   const ID3v2::FrameFactory *ID3v2FrameFactory;
   long ID3v2Location;
-  unsigned int ID3v2OriginalSize;
+  long ID3v2OriginalSize;
 
   long ID3v1Location;
 
@@ -169,7 +169,7 @@ bool TrueAudio::File::save()
     insert(data, d->ID3v2Location, d->ID3v2OriginalSize);
 
     if(d->ID3v1Location >= 0)
-      d->ID3v1Location += (data.size() - d->ID3v2OriginalSize);
+      d->ID3v1Location += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
 
     d->ID3v2OriginalSize = data.size();
   }
index 909c55906df2d5dbed696dc339423adc2f670fb2..ef92f4bdfc812657820e14bbf4ebf5b4e1fc394b 100644 (file)
@@ -62,7 +62,7 @@ public:
   }
 
   long APELocation;
-  unsigned int APESize;
+  long APESize;
 
   long ID3v1Location;
 
@@ -174,7 +174,7 @@ bool WavPack::File::save()
     insert(data, d->APELocation, d->APESize);
 
     if(d->ID3v1Location >= 0)
-      d->ID3v1Location += (data.size() - d->APESize);
+      d->ID3v1Location += (static_cast<long>(data.size()) - d->APESize);
 
     d->APESize = data.size();
   }