[PATCH] D26347: Fix memory leaks (coverity issues 1365586 & 1365591)

Sylvestre Ledru via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 7 00:26:58 PST 2016


sylvestre.ledru created this revision.
sylvestre.ledru added a reviewer: hfinkel.
sylvestre.ledru added a subscriber: llvm-commits.
sylvestre.ledru set the repository for this revision to rL LLVM.

Repository:
  rL LLVM

https://reviews.llvm.org/D26347

Files:
  lib/Support/APFloat.cpp


Index: lib/Support/APFloat.cpp
===================================================================
--- lib/Support/APFloat.cpp
+++ lib/Support/APFloat.cpp
@@ -1686,8 +1686,10 @@
   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 @@
     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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26347.77017.patch
Type: text/x-patch
Size: 948 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161107/c65e70b9/attachment.bin>


More information about the llvm-commits mailing list