diff options
author | Michael <michael64> | 2021-12-22 23:49:52 +0300 |
---|---|---|
committer | Ray Molenkamp <github@lazydodo.com> | 2021-12-22 23:49:52 +0300 |
commit | c6e7fc97443ebc5ae44c07fc81b3e7eb2cf4f325 (patch) | |
tree | bf54647e34547dec6ce8d5a46fccd4703d9fc391 /source/blender/compositor/intern | |
parent | 0fd72a98ac1377a385b6558bf34a7cb372677ac1 (diff) |
Fix: Large stack allocation in compositor
When COM_EXPORT_GRAPHVIZ is enabled, DebugInfo::graphviz
uses a char[1000000] as local variable. When this function
is called this is allocated on the stack, which has a size
of just 1MB on mac and may cause a stack overflow.
This patch allocates the memory on the heap and frees
the memory at the end of the function.
Reviewed By: LazyDodo
Differential Revision: https://developer.blender.org/D13628
Diffstat (limited to 'source/blender/compositor/intern')
-rw-r--r-- | source/blender/compositor/intern/COM_Debug.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/compositor/intern/COM_Debug.cc b/source/blender/compositor/intern/COM_Debug.cc index 50a69e55b2b..8525e2fde50 100644 --- a/source/blender/compositor/intern/COM_Debug.cc +++ b/source/blender/compositor/intern/COM_Debug.cc @@ -431,8 +431,9 @@ void DebugInfo::graphviz(const ExecutionSystem *system, StringRefNull name) if (!COM_EXPORT_GRAPHVIZ) { return; } - char str[1000000]; - if (graphviz_system(system, str, sizeof(str) - 1)) { + const int max_textlength = 1000000; + char *str = (char *)MEM_mallocN(max_textlength, __func__); + if (graphviz_system(system, str, max_textlength - 1)) { char basename[FILE_MAX]; char filename[FILE_MAX]; @@ -451,6 +452,7 @@ void DebugInfo::graphviz(const ExecutionSystem *system, StringRefNull name) fputs(str, fp); fclose(fp); } + MEM_freeN(str); } static std::string get_operations_export_dir() |