fix a malloc overflow when doing mkd_anchor_format()

This commit is contained in:
david parsons
2020-03-28 23:14:23 -07:00
parent 2e900346a0
commit 1003923bca
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -233,7 +233,7 @@ mkd_anchor_format(char *s, int len, int labelformat, mkd_flag_t *flags)
int h4anchor = !is_flag_set(flags, MKD_URLENCODEDANCHOR);
static const unsigned char hexchars[] = "0123456789abcdef";
needed = labelformat ? (4*len) : len;
needed = (labelformat ? (4*len) : len) + 2; /* +2 for L & \0 */
if ( (res = malloc(needed)) == NULL )
return NULL;
+2 -2
View File
@@ -28,14 +28,14 @@ mkd_toc(Document *p, char **doc)
Cstring res;
int size;
int first = 1;
#if 0
#if HAVE_NAMED_INITIALIZERS
static mkd_flag_t islabel = { { [IS_LABEL] = 1 } };
#else
mkd_flag_t islabel;
mkd_init_flags(&islabel);
#endif
set_mkd_flag(&islabel, IS_LABEL);
#endif
if ( !(doc && p && p->ctx) ) return -1;