summaryrefslogtreecommitdiff
path: root/src/xml.c
diff options
context:
space:
mode:
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 4885d0a..6956efb 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);
}
@@ -64,7 +66,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) {
@@ -79,12 +82,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_HEADER:
- sprintf(buffer, " level=\"%d\"", node->as.header.level);
+ snprintf(buffer, BUFFER_SIZE, " level=\"%d\"", node->as.header.level);
cmark_strbuf_puts(xml, buffer);
break;
case CMARK_NODE_CODE_BLOCK: