diff --git a/lib/public/share.php b/lib/public/share.php
index 91c5c477c8dabb654d1fbb40fea7251ed1eb3d07..91b0ef6dc695dd2ee1a436ffddc486c19338e5ab 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -463,7 +463,7 @@ class Share {
 				} else {
 					// reuse the already set password, but only if we change permissions
 					// otherwise the user disabled the password protection
-					if ($checkExists && (int)$permissions !== $oldPermissions) {
+					if ($checkExists && (int)$permissions !== (int)$oldPermissions) {
 						$shareWith = $checkExists['share_with'];
 					}
 				}