From f327285ab3c5fcf60659cdb100b640f538b447ba Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Wed, 31 Jul 2013 09:46:07 +0100 Subject: [PATCH] MDL-40947: Fix segmentation fault issue in get_fast_modinfo. --- lib/modinfolib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/modinfolib.php b/lib/modinfolib.php index 19b12c330c6..d48504ec640 100644 --- a/lib/modinfolib.php +++ b/lib/modinfolib.php @@ -1414,8 +1414,10 @@ function get_fast_modinfo($courseorid, $userid = 0, $resetonly = false) { if (count($cache) > MAX_MODINFO_CACHE_SIZE) { reset($cache); $key = key($cache); - unset($cache[$key]->instances); - unset($cache[$key]->cms); + // Unsetting static variable in PHP is percular, it removes the reference, + // but data remain in memory. Prior to unsetting, the varable needs to be + // set to empty to remove its remains from memory. + $cache[$key] = ''; unset($cache[$key]); }