mathutils.h: add missing alloc checks

Bug: aomedia:3276
Change-Id: I31e3ff9ebea3d546c477db37f33af36f72f3307a
diff --git a/aom_dsp/mathutils.h b/aom_dsp/mathutils.h
index a52a2df..3ffca8a 100644
--- a/aom_dsp/mathutils.h
+++ b/aom_dsp/mathutils.h
@@ -70,6 +70,7 @@
   double *AtA, *Atb;
   if (!scratch) {
     scratch_ = (double *)aom_malloc(sizeof(*scratch) * n * (n + 1));
+    if (!scratch_) return 0;
     scratch = scratch_;
   }
   AtA = scratch;
@@ -138,6 +139,7 @@
   int flag, i, its, j, jj, k, l, nm;
   double anorm, c, f, g, h, s, scale, x, y, z;
   double *rv1 = (double *)aom_malloc(sizeof(*rv1) * (n + 1));
+  if (!rv1) return 0;
   g = scale = anorm = 0.0;
   for (i = 0; i < n; i++) {
     l = i + 1;
@@ -333,8 +335,8 @@
       nrV[i] = &V[i * N];
     }
   } else {
-    if (nrU) aom_free(nrU);
-    if (nrV) aom_free(nrV);
+    aom_free(nrU);
+    aom_free(nrV);
     return 1;
   }