]> git.proxmox.com Git - pve-container.git/commitdiff
fix #1792: Do not assign vars in conditional statement
authorWolfgang Link <w.link@proxmox.com>
Tue, 5 Jun 2018 10:58:47 +0000 (12:58 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 6 Jun 2018 13:26:22 +0000 (15:26 +0200)
If a variable is defined and assigned in a conditional statement,
it is not defined behavior in Perl.

For more inforamtion about this behavior see
https://perldoc.perl.org/perlsyn.html#Statement-Modifiers

"NOTE: The behaviour of a my, state, or our modified with a statement
modifier conditional or loop construct (for example, my $x if ... )
is undefined.
The value of the my variable may be undef, any previously assigned
value, or possibly anything else.
Don't rely on it. Future versions of perl might do something different
from the version of perl you try it out on. Here be dragons."

src/PVE/LXC.pm

index bfca9c13cee7c91dbb3ac42ceb64dfb79f9fb105..4be1579b2df5e435f3c03a8c642d8e8940206205 100644 (file)
@@ -1208,7 +1208,8 @@ sub mountpoint_mount {
     }
     my $readonly = $mountpoint->{ro};
 
-    my @extra_opts = ('-o', $optstring) if $optstring;
+    my @extra_opts;
+    @extra_opts = ('-o', $optstring) if $optstring;
 
     if ($storage) {