From: Christoph Wurst Date: Thu, 12 May 2022 07:51:37 +0000 (+0200) Subject: Always free the DB result in QBMapper::findEntities X-Git-Tag: v25.0.0beta1~438^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1cd05a06fafcca6d115ec4e4b210704439c1ab14;p=nextcloud-server.git Always free the DB result in QBMapper::findEntities Without this patch it only happened if the code ran through without any errors. Now the result is also freed in the case of an error. Signed-off-by: Christoph Wurst --- diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index fa753a09dcf..2491fd83f4a 100644 --- a/lib/public/AppFramework/Db/QBMapper.php +++ b/lib/public/AppFramework/Db/QBMapper.php @@ -334,16 +334,15 @@ abstract class QBMapper { */ protected function findEntities(IQueryBuilder $query): array { $result = $query->executeQuery(); - - $entities = []; - - while ($row = $result->fetch()) { - $entities[] = $this->mapRowToEntity($row); + try { + $entities = []; + while ($row = $result->fetch()) { + $entities[] = $this->mapRowToEntity($row); + } + return $entities; + } finally { + $result->closeCursor(); } - - $result->closeCursor(); - - return $entities; }