replaced MAXMSG with MAXID
added a check if demandName is too long
This commit is contained in:
mariosmsk
2019-03-26 17:19:08 +02:00
parent 8c5e383692
commit 08799eb276
2 changed files with 7 additions and 4 deletions

View File

@@ -1234,7 +1234,7 @@ int DLLEXPORT EN_setoption(EN_Project p, int option, double value)
if (demand->Pat == tmpPat)
{
demand->Pat = pat;
demand->Name = xstrcpy(&demand->Name, "", MAXMSG);
demand->Name = xstrcpy(&demand->Name, "", MAXID);
}
}
}
@@ -2776,11 +2776,14 @@ int DLLEXPORT EN_setdemandname(EN_Project p, int nodeIndex, int demandIndex,
if (!p->Openflag) return 102;
if (nodeIndex <= 0 || nodeIndex > p->network.Njuncs) return 203;
// Check that demandName is not too long
if (strlen(demandName) > MAXID) return 250;
// Locate demand category record and assign demandName to it
for (d = p->network.Node[nodeIndex].D;
n < demandIndex && d->next != NULL; d = d->next) n++;
if (n != demandIndex) return 253;
d->Name = xstrcpy(&d->Name, demandName, MAXMSG);
d->Name = xstrcpy(&d->Name, demandName, MAXID);
return 0;
}