fix segmentation fault when idc is default #38
Merged
+24
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
idc的默认值需要设置为NULL,要不然会发生段错误,在php-5.6.14下重现代码为
var_dump(Qconf::getBatchConf("/abcd","test"));正常
var_dump(Qconf::getBatchConf("/abcd"));段错误
原因是未对idc进行初始化为为NULL,idc未传值时,这是一个非法指针,以getBatchConf为例,最后实际调的是qconf.cc中的qconf_get_batch_conf_方法,这里有一段代码if (NULL != idc) tmp_idc.assign(idc); 这个显然对一个非法指针进行了操作。
看了下提交历史,应该是之前的一个版本中为兼容php7修改int为size_t时,把idc字符串的初始化也给去掉了。