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
This commit is contained in:
parent
0fd72a98ac
commit
c6e7fc9744
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue