Git: handle excess of cylinders or weightsystems gracefully

Currently, the git parser happily trashes memory if a git repository
contains too many weightsystems or cylinders. This should only happen
in testing, but nevertheless try to handle it gracefully and ignore
excess cylinders / weightsystems.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-07-09 21:15:35 +02:00 committed by Lubomir I. Ivanov
parent 25bee36fcc
commit 9eb860d45d

View file

@ -391,6 +391,9 @@ static void parse_dive_cylinder(char *line, struct membuffer *str, void *_dive)
struct dive *dive = _dive;
cylinder_t *cylinder = dive->cylinder + cylinder_index;
if (cylinder_index >= MAX_CYLINDERS)
return;
cylinder->type.description = get_utf8(str);
for (;;) {
char c;
@ -423,6 +426,9 @@ static void parse_dive_weightsystem(char *line, struct membuffer *str, void *_di
struct dive *dive = _dive;
weightsystem_t *ws = dive->weightsystem + weightsystem_index;
if (weightsystem_index >= MAX_WEIGHTSYSTEMS)
return;
weightsystem_index++;
ws->description = get_utf8(str);
for (;;) {