引自: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.