Fix (unreported) potential leak in Main freeing function.

Could happen in case a 'split-by-libraries' Main is passed to
`BKE_main_free`.
This commit is contained in:
Bastien Montagne 2023-02-22 16:37:15 +01:00
parent e35afd8a1d
commit 3e5ce23c99
1 changed files with 7 additions and 0 deletions

View File

@ -40,6 +40,13 @@ Main *BKE_main_new()
void BKE_main_free(Main *mainvar)
{
/* In case this is called on a 'split-by-libraries' list of mains.
*
* Should not happen in typical usages, but can occur e.g. if a file reading is aborted. */
if (mainvar->next) {
BKE_main_free(mainvar->next);
}
/* also call when reading a file, erase all, etc */
ListBase *lbarray[INDEX_ID_MAX];
int a;