Patch from upstream repo suggested by Anton Yuzhaninov <citrin@citrin.ru>. PR: ports/182159 Submitted by: Jeremy Chadwick <jdc@koitsu.org>