diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index 89024e30192e6a5ff62136b43eae97af02ec12cb..c0f2ada2ed90d776c2cc8971d3613a1292f94a25 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -2492,7 +2492,7 @@ class ContentObjectRenderer {
 			$length = isset($conf['strPad.']['length.']) ? $this->stdWrap($conf['strPad.']['length'], $conf['strPad.']['length.']) : $conf['strPad.']['length'];
 			$length = intval($length);
 		}
-		if (!empty($conf['strPad.']['padWith'])) {
+		if (isset($conf['strPad.']['padWith']) && strlen($conf['strPad.']['padWith']) > 0) {
 			$padWith = isset($conf['strPad.']['padWith.']) ? $this->stdWrap($conf['strPad.']['padWith'], $conf['strPad.']['padWith.']) : $conf['strPad.']['padWith'];
 		}
 		if (!empty($conf['strPad.']['type'])) {
diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
index 8bdd823447c13cf80f4f06a7afcdaf2b4500fee9..d9ccf99159f9e9e2c505efd028926839f040cd9e 100644
--- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
+++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
@@ -858,6 +858,15 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 				),
 				'__Alien___',
 			),
+			'pad string with padWith 0 and type both and length 10' => array(
+				'Alien',
+				array(
+					'length' => '10',
+					'padWith' => '0',
+					'type' => 'both',
+				),
+				'00Alien000',
+			),
 			'pad string with padWith ___ and type both and length 6' => array(
 				'Alien',
 				array(