mirror of
https://github.com/Orc/discount.git
synced 2026-09-25 04:10:00 +03:00
fix a malloc overflow when doing mkd_anchor_format()
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user