diff options
Diffstat (limited to 'src/html.c')
-rw-r--r-- | src/html.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -29,11 +29,12 @@ struct render_state { static void S_render_sourcepos(cmark_node *node, cmark_strbuf *html, int options) { - char buffer[100]; + const size_t BUFFER_SIZE = 100; + char buffer[BUFFER_SIZE]; if (CMARK_OPT_SOURCEPOS & options) { - sprintf(buffer, " data-sourcepos=\"%d:%d-%d:%d\"", - cmark_node_get_start_line(node), cmark_node_get_start_column(node), - cmark_node_get_end_line(node), cmark_node_get_end_column(node)); + snprintf(buffer, BUFFER_SIZE, " data-sourcepos=\"%d:%d-%d:%d\"", + cmark_node_get_start_line(node), cmark_node_get_start_column(node), + cmark_node_get_end_line(node), cmark_node_get_end_column(node)); cmark_strbuf_puts(html, buffer); } } @@ -46,7 +47,8 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, char start_heading[] = "<h0"; char end_heading[] = "</h0"; bool tight; - char buffer[100]; + const size_t BUFFER_SIZE = 100; + char buffer[BUFFER_SIZE]; bool entering = (ev_type == CMARK_EVENT_ENTER); @@ -104,7 +106,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, S_render_sourcepos(node, html, options); cmark_strbuf_puts(html, ">\n"); } else { - sprintf(buffer, "<ol start=\"%d\"", start); + snprintf(buffer, BUFFER_SIZE, "<ol start=\"%d\"", start); cmark_strbuf_puts(html, buffer); S_render_sourcepos(node, html, options); cmark_strbuf_puts(html, ">\n"); |