Fix #1243
(cherry picked from commit 50dab390f5ae921c99cd9f3f72071f2f6116099b)