vmware/core: Support drm interface version 1.0.0
[mesa.git] / progs / demos / fire.c
index 3db45418fadfc559fd5761ea1fd5ab4bd3238307..bb912fb44735f027fbbf42bce167448d10e219ab 100644 (file)
@@ -6,6 +6,7 @@
  *            Humanware s.r.l.
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -725,8 +726,13 @@ main(int ac, char **av)
 
    maxage = 1.0 / dt;
 
-   if (ac == 2)
+   if (ac == 2) {
       np = atoi(av[1]);
+      if (np <= 0 || np > 1000000) {
+         fprintf(stderr, "Invalid input.\n");
+         exit(-1);
+      }
+   }
 
    if (ac == 4) {
       WIDTH = atoi(av[2]);
@@ -758,7 +764,9 @@ main(int ac, char **av)
    glFogfv(GL_FOG_COLOR, fogcolor);
    glFogf(GL_FOG_DENSITY, 0.1);
 
+   assert(np > 0);
    p = (part *) malloc(sizeof(part) * np);
+   assert(p);
 
    for (i = 0; i < np; i++)
       setnewpart(&p[i]);