Apparently the original implementation from facebook was incorrect.
Fixed it, sadly this does mean we need to call vsnprintf twice.
Once to find out the size involved, a second time to apply.