tac: do not let failed allocation cause immediate exit
authorJim Meyering <meyering@redhat.com>
Tue, 18 Oct 2011 10:04:02 +0000 (12:04 +0200)
committerJim Meyering <meyering@redhat.com>
Wed, 19 Oct 2011 07:31:52 +0000 (09:31 +0200)
* src/tac.c (temp_stream): Don't exit immediately upon failed heap
allocation, here.  That would inhibit processing of any additional
command-line arguments.

src/tac.c

index 6a7e510..7cc562e 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -430,7 +430,12 @@ temp_stream (FILE **fp, char **file_name)
     {
       char const *t = getenv ("TMPDIR");
       char const *tempdir = t ? t : DEFAULT_TMPDIR;
-      tempfile = file_name_concat (tempdir, "tacXXXXXX", NULL);
+      tempfile = mfile_name_concat (tempdir, "tacXXXXXX", NULL);
+      if (tempdir == NULL)
+        {
+          error (0, 0, _("memory exhausted"));
+          return false;
+        }
 
       /* FIXME: there's a small window between a successful mkstemp call
          and the unlink that's performed by record_or_unlink_tempfile.