-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
File: histo.c
Function: ffhist
The ffhist function declares a local histType structure without
initialization and fails to initialize the numIterCols, iterCols,
parsers, and startCols fields. When ffwritehisto is called, it
invokes fits_iterate_data with these uninitialized values, causing
undefined behavior (typically BAD_COL_NUM error 302 or segfault).
The ffhist3 function works correctly because it calls fits_make_histd
which properly initializes all histData fields.
Workaround: Use ffhist3 instead of ffhist.
Reproduction:
fitsfile *f;
int status = 0;
char colname[4][FLEN_VALUE] = {"X", "", "", ""};
double minin[4] = {0}, maxin[4] = {6}, binsizein[4] = {1};
char minname[4][FLEN_VALUE] = {""};
char maxname[4][FLEN_VALUE] = {""};
char binname[4][FLEN_VALUE] = {""};
/* Create and open a table with column X ... */
fits_open_file(&f, "table.fits[1]", READWRITE, &status);
ffhist(&f, "!hist.fits", TINT, 1, colname,
minin, maxin, binsizein,
minname, maxname, binname,
1.0, "", 0, NULL, &status);
/* status is 302 (BAD_COL_NUM) */
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels