Check for NULL when allocating memory for bpp_q3.
authorLuc Trudeau <luc.trudeau.1@ens.etsmtl.ca>
Wed, 24 Feb 2016 23:47:45 +0000 (18:47 -0500)
committerNathan E. Egge <negge@dgql.org>
Wed, 24 Feb 2016 23:47:45 +0000 (18:47 -0500)
Signed-off-by: Nathan E. Egge <negge@dgql.org>
examples/analyzer.cc

index ab543be..ea5ac34 100644 (file)
@@ -541,6 +541,11 @@ bool TestPanel::open(const wxString &path) {
   if (bit_accounting) {
     bpp_q3 =
      (double *)malloc(sizeof(*bpp_q3)*dd.getFrameWidth()*dd.getFrameHeight());
+    if (bpp_q3 == NULL) {
+      fprintf(stderr, "Could not allocate memory for bit accounting\n");
+      close();
+      return false;
+    }
     if (!dd.setAccountingEnabled(true)) {
       fprintf(stderr, "Could not enable accounting\n");
       close();