Permalink
Browse files

Remove an undefined behaviour and add a big comment

  • Loading branch information...
1 parent b7f31e9 commit 90a9675dbab69fc3a4734e6e8141f1324bb61522 @ndmitchell committed Nov 30, 2016
Showing with 5 additions and 1 deletion.
  1. +5 −1 cbits/hexml.c
View
@@ -532,7 +532,11 @@ document* document_parse(char* s, int slen)
d->nodes.nodes[0].outer = start_length(0, slen);
d->nodes.nodes[0].inner = start_length(0, slen);
d->nodes.nodes[0].attrs = start_length(0, 0);
- d->nodes.nodes[0].nodes = parse_content(d);
+
+ // Introduce an intermediate result, otherwise behaviour is undefined
+ // because there is no guaranteed ordering between LHS and RHS evaluation
+ str content = parse_content(d);
+ d->nodes.nodes[0].nodes = content;
if (d->cursor < d->end && d->error_message == NULL)
{

0 comments on commit 90a9675

Please sign in to comment.