【PIHM模型】PIHM模型存在Bug

引自:https://sourceforge.net/p/pihmmodel/bugs/
在这里插入图片描述
BUGS如下所列:

1.Uninitialized variable iCounter

Various TSD_xx variables are allocated, but never initialized. This causes SEGFAULT. The first one happens in Interpolation() @ f.c. Tested under MS Windows and mingw gcc 4.5.0.

问题:分配了各种TSD_xx变量,但从未初始化。

2.closed soil_file is used instead of geol_file @read_alloc.c

Debugging with mudflap ( http://gcc.gnu.org/wiki/Mudflap_Pointer_Debugging ) helped to track down misuse of a file stream around line 267 @ read_alloc.c . It is likely it should reads as
fscanf(geol_file, “%lf %lf”, &(DS->Geol[i].Alpha), &(DS->Geol[i].Beta));
fscanf(geol_file, “%lf %lf %lf”, &(DS->Geol[i].vAreaF),&(DS->Geol[i].macKsatH),&(DS->Geol[i].macD));
whereas soil_file is used, which even was previously closed.

问题:错误使用soil_file

3. multiple buffer overflows before fopen()

strlen() doesn’t include terminating zero, thus all buffers for files were 1 byte less than necessary, and strcat() wrote outside of the buffer. It resulted in sporadic SEGFAULTs under MS Windows when built with gcc from MinGW.

问题:strlen()不包括结束0,因此所有文件的缓冲区都比需要少1个字节,并且strcat()在缓冲区外写入。当使用gcc从MinGW构建时,它会在MS Windows下导致零星的段错误。

4.incorrect allocation size calculation

Double pointers to realtype are used throughout the code, meanwhile sizeof(realtype) is used to allocate first dimension instead of sizeof(realtype*). Here is an incorrect example from read_alloc.c :
DS->TSD_Riv[i].TS = (realtype **)malloc((DS->TSD_Riv[i].length)*sizeof(realtype))

问题:在整个代码中使用指向realtype的双指针,同时使用sizeof(realtype)来分配第一个维度,而不是sizeof(realtype*)。
错误实例:

DS->TSD_Riv[i].TS = (realtype **)malloc((DS->TSD_Riv[i].length)*sizeof(realtype))

5.incorrect size of fn[] array in read_alloc.c

char *fn[9];
should be replaced with
char *fn[10];
if it is necessary to store filename for .calib file.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

WW、forever

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值