Shlomi Fish avatar Shlomi Fish committed 511f34b

Regression bug fix: warning instead of exception.

should return undef() instead of throwing an exception.
- https://rt.cpan.org/Ticket/Display.html?id=77039
- Thanks to Adam D. Barrat for noticing that, and Gregor Herrmann
from Debian for reporting this issue.

Comments (0)

Files changed (2)

config-inifiles/Changes

+* Regression bug fix: temporary file creation error should generate a warning
+and return undef() instead of throwing an exception.
+    - https://rt.cpan.org/Ticket/Display.html?id=77039
+    - Thanks to Adam D. Barrat for noticing that, and Gregor Herrmann
+    from Debian for reporting this issue.
+
 Version 2.72    ( Sat May  5 19:19:09 IDT 2012 )
 ------------------------------------------------
 

config-inifiles/lib/Config/IniFiles.pm

         #carp "Using mode $self->{file_mode} for file $file";
     }
 
-    my ($fh, $new_file) = tempfile(
-        "temp.ini-XXXXXXXXXX",
-        DIR => dirname($filename)
-    );
+    my ($fh, $new_file);
+
+    # We need to trap the exception that tempfile() may throw and instead
+    # carp() and return undef() because that was the previous behaviour:
+    #
+    # See RT #77039 ( https://rt.cpan.org/Ticket/Display.html?id=77039 )
+    eval {
+        ($fh, $new_file) = tempfile(
+            "temp.ini-XXXXXXXXXX",
+            DIR => dirname($filename)
+        );
+    };
+
+    if ($@)
+    {
+        carp( "Unable to write temp config file: $!" );
+        return undef;
+    }
+
     $self->OutputConfigToFileHandle($fh, $parms{-delta});
     close($fh);
     if (!rename( $new_file, $filename )) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.