It seems to me that your fix is appropriate, but I hope someone with actual knowledge of C will comment.
Thanks Jamie!