Include Henry's out-of-memory check.
[samtools.git] / debian / patches / razip-oom-check
diff --git a/debian/patches/razip-oom-check b/debian/patches/razip-oom-check
new file mode 100644 (file)
index 0000000..d4cc299
--- /dev/null
@@ -0,0 +1,18 @@
+--- a/razip.c  2011-10-20 11:05:21.020305754 -0700
++++ b/razip.c  2011-10-20 11:48:26.208271871 -0700
+@@ -79,7 +79,13 @@
+                       if(pstdout){
+                               f_dst = fileno(stdout);
+                       } else {
+-                              char *name = malloc(sizeof(strlen(argv[optind]) + 5));
++                              char *name = (char *)malloc(sizeof(char) * (strlen(argv[optind]) + 5));
++                              if (name == NULL)
++                              {
++                                      fprintf(stderr, " -- Out of memory --\n");
++                                      return 1;
++                              }
++
+                               strcpy(name, argv[optind]);
+                               strcat(name, ".rz");
+                               f_dst = write_open(name, is_forced);
+