Commit: c6e7fc97443ebc5ae44c07fc81b3e7eb2cf4f325 Author: Michael Date: Wed Dec 22 13:49:52 2021 -0700 Branches: master https://developer.blender.org/rBc6e7fc97443ebc5ae44c07fc81b3e7eb2cf4f325
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 =================================================================== M source/blender/compositor/intern/COM_Debug.cc =================================================================== 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() _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
