trim crash fix

This commit is contained in:
2020-05-07 17:41:23 +02:00
parent 1741c84406
commit e56b431dc3

View File

@ -742,17 +742,21 @@ int setTrimbits(int *trimbits) {
} }
int setAllTrimbits(int val) { int setAllTrimbits(int val) {
int trimbits[NCHAN]; int *trimbits = malloc(sizeof(int) * NCHAN);
int ichan = 0; int ichan = 0;
for (ichan = 0; ichan < NCHAN; ++ichan) { for (ichan = 0; ichan < NCHAN; ++ichan) {
trimbits[ichan] = val; trimbits[ichan] = val;
} }
if (setTrimbits(trimbits) == FAIL) { if (setTrimbits(trimbits) == FAIL) {
LOG(logERROR, ("Could not set all trimbits to %d\n", val)); LOG(logERROR, ("Could not set all trimbits to %d\n", val));
free(trimbits);
return FAIL; return FAIL;
} }
// setSettings(UNDEFINED);
// LOG(logERROR, ("Settings has been changed to undefined (random "
// "trim file)\n"));
LOG(logINFO, ("All trimbits have been set to %d\n", val)); LOG(logINFO, ("All trimbits have been set to %d\n", val));
free(trimbits);
return OK; return OK;
} }