[BUGFIX] Endless loop in flushOutputBuffers()

Change-Id: I87f998211d12f2d7c40a582f8b2c605f2edcaed0
Resolves: #40126
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: https://review.typo3.org/15496
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Mario Rimann
Reviewed-by: Sascha Egerer
Tested-by: Sascha Egerer
Reviewed-by: Steffen Gebert
Tested-by: Steffen Gebert