穿过OpenSSL中的一行,让我做了双重拍摄......
if (!*pos)
return NULL;
if (!*pos || ((*pos)->flags == FLAGS))
return blah;
Run Code Online (Sandbox Code Playgroud)
是否存在(性能/安全性/可靠性)差异,而不是:
if (!*pos)
return NULL;
if (*pos && ((*pos)->flags == FLAGS))
return blah;
Run Code Online (Sandbox Code Playgroud)
谢谢,陈兹
小智 6
为什么不:
if (!*pos)
return NULL;
if ((*pos)->flags == FLAGS)
return blah;
Run Code Online (Sandbox Code Playgroud)
原始代码(删除的评论)是:
if (!pos)
return NULL;
if (!*pos)
return BIO_new(BIO_s_null());
if (!*pos || ((*pos)->flags == ASN1_STRING_FLAG_CONT))
return BIO_new(BIO_s_mem());
return BIO_new_mem_buf((*pos)->data, (*pos)->length);
Run Code Online (Sandbox Code Playgroud)
如果测试是出于一些可疑的安全原因,那么第三个测试不应该是:
if ( pos && *pos && ((*pos)->flags == ASN1_STRING_FLAG_CONT))
Run Code Online (Sandbox Code Playgroud)
当然,你得到的功能越来越荒谬.此外,粗略检查显示这种风格没有在文件的其他地方使用,所以我认为我们可以把它写给一个小程序员boo-boo.