Skip to content

Commit 03e7644

Browse files
committed
Fix improper handling of null data in cache
1 parent 02abbbb commit 03e7644

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

info/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 2025-09-01
4+
5+
### Fixed
6+
7+
- Improper handling of null data in 'Set-CachedData'.
8+
39
## 2025-08-30
410

511
### Added

src/helper/Cache.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ function Set-CachedData {
5353
[String] $Name,
5454

5555
[Parameter(Mandatory = $true)]
56+
[AllowEmptyCollection()]
5657
[Object[]] $Data
5758
)
5859

src/helper/Environment.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ function Get-CurrentUserDenySid {
2020
param()
2121

2222
if (-not (Test-CachedData -Name "CurrentUserDenySids")) {
23-
$CurrentUserDenySids = [string[]](Get-TokenInformationGroup -InformationClass Groups | Where-Object { $_.Attributes.Equals("UseForDenyOnly") } | Select-Object -ExpandProperty SID)
23+
$CurrentUserDenySids = @()
24+
Get-TokenInformationGroup -InformationClass Groups | Where-Object { $_.Attributes.Equals("UseForDenyOnly") } | Select-Object -ExpandProperty SID | ForEach-Object {
25+
$CurrentUserDenySids += $_
26+
}
2427
Set-CachedData -Name "CurrentUserDenySids" -Data $CurrentUserDenySids
2528
}
2629

@@ -33,7 +36,8 @@ function Get-InstalledApplication {
3336
param ()
3437

3538
if (-not (Test-CachedData -Name "InstalledApplicationList")) {
36-
$InstalledApplicationList = Get-InstalledApplicationHelper
39+
$InstalledApplicationList = @()
40+
Get-InstalledApplicationHelper | ForEach-Object { $InstalledApplicationList += $_ }
3741
Set-CachedData -Name "InstalledApplicationList" -Data $InstalledApplicationList
3842
}
3943

0 commit comments

Comments
 (0)