]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix undef ref for user-defined formatter without output
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 6 Apr 2022 13:33:37 +0000 (06:33 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 6 Apr 2022 13:33:37 +0000 (06:33 -0700)
lib/Perl/Tidy.pm

index cf25acd0c47d12bfe265eb39b9590dbe193af39e..6594d4e2c29a71b4f7cc1da09b237f5fec8528e6 100644 (file)
@@ -1412,7 +1412,7 @@ EOM
         my $use_destination_buffer;
         my $encode_destination_buffer;
         my $ref_destination_stream = ref($destination_stream);
-        if ($ref_destination_stream) {
+        if ( $ref_destination_stream && !$user_formatter ) {
             $use_destination_buffer = 1;
             $output_file            = \$destination_buffer;
 
@@ -1847,13 +1847,13 @@ EOM
             if ( ref($destination_stream) eq 'SCALAR' ) {
                 ${$destination_stream} = $destination_buffer;
             }
-            else {
+            elsif ($destination_buffer) {
                 my @lines = split /^/, $destination_buffer;
                 if ( ref($destination_stream) eq 'ARRAY' ) {
                     @{$destination_stream} = @lines;
                 }
 
-                # destination is object with print method
+                # destination stream must be an object with print method
                 else {
                     foreach (@lines) {
                         $destination_stream->print($_);
@@ -1863,6 +1863,11 @@ EOM
                     }
                 }
             }
+            else {
+
+                # Empty destination buffer not going to a string ... could
+                # happen for example if user deleted all pod or comments
+            }
         }
         else {