I recommend to apply the patch which is provided by Magento. So please don't make direct changes in the core files of the Magento. It is not correct approach to resolve the core issues.
Always apply the patch if Magento has provided and If not and they have resolved the issue in latest version then kindly upgrade your Magento to the latest version step by step. And do your end to end testing for the website before moving to production.
For the above issue, Kindly apply MAGETWO-93036 patch. You can download the patch file from here: https://magento.com/tech-resources/download#download2224
You can see GitHub-14968 reported issue in GitHub for further information.
Kindly read suggestion and instruction provided by Magento before applying patches. If you will ignore it then you might get an issue after applying patches.