Skip to content

Commit

Permalink
core: parser rr - check for rr value before serializing
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Mar 4, 2024
1 parent 69883dd commit 6ee26a3
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/core/parser/parse_rr.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,20 +444,28 @@ int print_rr_body(
i = (nb_recs == NULL) ? 0 : *nb_recs;

while(i < n) {
memcpy(cp, route[i].s, route[i].len);
cp += route[i].len;
if(++i < n)
*(cp++) = ',';
if(route[i].s != NULL) {
memcpy(cp, route[i].s, route[i].len);
cp += route[i].len;
if(++i < n)
*(cp++) = ',';
} else {
i++;
}
}
} else {

i = (nb_recs == NULL) ? n - 1 : (n - *nb_recs - 1);

while(i >= 0) {
memcpy(cp, route[i].s, route[i].len);
cp += route[i].len;
if(i-- > 0)
*(cp++) = ',';
if(route[i].s != NULL) {
memcpy(cp, route[i].s, route[i].len);
cp += route[i].len;
if(i-- > 0)
*(cp++) = ',';
} else {
i--;
}
}
}
oroute->len = cp - start;
Expand Down

0 comments on commit 6ee26a3

Please sign in to comment.