Skip to content
Snippets Groups Projects
Commit d1a8afb06813 authored by Florian Weimer's avatar Florian Weimer
Browse files

yaml_stack_extend: guard against integer overflow

parent ff6c0eaafb5e
No related branches found
No related tags found
No related merge requests found
...@@ -117,7 +117,12 @@ ...@@ -117,7 +117,12 @@
YAML_DECLARE(int) YAML_DECLARE(int)
yaml_stack_extend(void **start, void **top, void **end) yaml_stack_extend(void **start, void **top, void **end)
{ {
void *new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2); void *new_start;
if ((char *)*end - (char *)*start >= INT_MAX / 2)
return 0;
new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2);
if (!new_start) return 0; if (!new_start) return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment