summaryrefslogtreecommitdiff
path: root/src/xml.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-01-18 09:26:14 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2016-01-18 09:26:14 -0800
commit7e1f8b8e49ca291a7757c55a8e02fc7a85d1434c (patch)
tree1c777b0fd81cb44d2dc50a95c915491b04bf6670 /src/xml.c
parentac812214f6fa81b201b8fcf3779ed8d2c3cfacf7 (diff)
parent0b5a8193fdc7b041023e44149a1d63b95ce98bfd (diff)
Merge branch 'master' of https://github.com/mbenelli/cmark into mbenelli-master
Diffstat (limited to 'src/xml.c')
-rw-r--r--src/xml.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/xml.c b/src/xml.c
index a06cdd3..b630810 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -34,7 +34,8 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
bool literal = false;
cmark_delim_type delim;
bool entering = (ev_type == CMARK_EVENT_ENTER);
- char buffer[100];
+ const size_t BUFFER_SIZE = 100;
+ char buffer[BUFFER_SIZE];
if (entering) {
indent(state);
@@ -42,8 +43,9 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
if (options & CMARK_OPT_SOURCEPOS && node->start_line != 0) {
- sprintf(buffer, " sourcepos=\"%d:%d-%d:%d\"", node->start_line,
- node->start_column, node->end_line, node->end_column);
+ snprintf(buffer, BUFFER_SIZE, " sourcepos=\"%d:%d-%d:%d\"",
+ node->start_line, node->start_column, node->end_line,
+ node->end_column);
cmark_strbuf_puts(xml, buffer);
}
@@ -67,7 +69,8 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
switch (cmark_node_get_list_type(node)) {
case CMARK_ORDERED_LIST:
cmark_strbuf_puts(xml, " type=\"ordered\"");
- sprintf(buffer, " start=\"%d\"", cmark_node_get_list_start(node));
+ snprintf(buffer, BUFFER_SIZE, " start=\"%d\"",
+ cmark_node_get_list_start(node));
cmark_strbuf_puts(xml, buffer);
delim = cmark_node_get_list_delim(node);
if (delim == CMARK_PAREN_DELIM) {
@@ -82,12 +85,12 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
default:
break;
}
- sprintf(buffer, " tight=\"%s\"",
- (cmark_node_get_list_tight(node) ? "true" : "false"));
+ snprintf(buffer, BUFFER_SIZE, " tight=\"%s\"",
+ (cmark_node_get_list_tight(node) ? "true" : "false"));
cmark_strbuf_puts(xml, buffer);
break;
case CMARK_NODE_HEADING:
- sprintf(buffer, " level=\"%d\"", node->as.heading.level);
+ snprintf(buffer, BUFFER_SIZE, " level=\"%d\"", node->as.heading.level);
cmark_strbuf_puts(xml, buffer);
break;
case CMARK_NODE_CODE_BLOCK: