This patch looks good. It is essentially the same as this Gnulib patch: https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=d2822d2338678c7deaa404d848ddbcf52fa9de31