Hello,
I found that the return value of i2d_re_X509_REQ_tbs() was changed since 8e39049.
Currently it returns 0 on some errors or 1 unexpectedly. Manpage says:
i2d_re_X509_tbs(), i2d_re_X509_CRL_tbs() and i2d_re_X509_REQ_tbs() return the length of encoded data or 0 on error.
I guess the NULL check for req parameter is enough, then returns the result of i2d_X509_REQ_INFO() straightforward.