[llvm] r286223 - Fix memory leaks (coverity issues 1365586 & 1365591)

Sylvestre Ledru via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 02:00:45 PST 2016


Author: sylvestre
Date: Tue Nov  8 04:00:45 2016
New Revision: 286223

URL: http://llvm.org/viewvc/llvm-project?rev=286223&view=rev
Log:
Fix memory leaks (coverity issues 1365586 & 1365591)

Reviewers: hfinkel

Subscribers: george.burgess.iv, malcolm.parsons, boris.ulasevich, llvm-commits

Differential Revision: https://reviews.llvm.org/D26347

Modified:
    llvm/trunk/lib/Support/APFloat.cpp

Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=286223&r1=286222&r2=286223&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Tue Nov  8 04:00:45 2016
@@ -1686,8 +1686,10 @@ IEEEFloat::opStatus IEEEFloat::remainder
   bool ignored;
   fs = V.convertToInteger(x, parts * integerPartWidth, true,
                           rmNearestTiesToEven, &ignored);
-  if (fs==opInvalidOp)
+  if (fs==opInvalidOp) {
+    delete[] x;
     return fs;
+  }
 
   fs = V.convertFromZeroExtendedInteger(x, parts * integerPartWidth, true,
                                         rmNearestTiesToEven);
@@ -1724,8 +1726,10 @@ IEEEFloat::opStatus IEEEFloat::mod(const
     bool ignored;
     fs = V.convertToInteger(x, parts * integerPartWidth, true,
                             rmTowardZero, &ignored);
-    if (fs==opInvalidOp)
+    if (fs==opInvalidOp) {
+      delete[] x;
       return fs;
+    }
 
     fs = V.convertFromZeroExtendedInteger(x, parts * integerPartWidth, true,
                                           rmNearestTiesToEven);




More information about the llvm-commits mailing list