Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion deploy/windows/nullsoft_installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,24 @@ Section "Install" SecMain
DetailPrint "Checking for 64 bit uninstaller"
SetRegView 64
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString"
StrCmp $R0 "" doInstall doUninstall
StrCmp $R0 "" doInstall checkUninstaller

checkUninstaller:
; Remove quotes from uninstaller path to check if file exists
StrCpy $R1 $R0 "" 1 ; Skip first quote
StrLen $R2 $R1
IntOp $R2 $R2 - 1 ; Remove last quote
StrCpy $R1 $R1 $R2
Comment on lines +70 to +73
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quote removal logic assumes the UninstallString always has quotes, but doesn't verify this assumption. If the registry value lacks quotes (e.g., from a corrupted registry or different installer version), this code will incorrectly trim the first and last characters of the actual path.

Consider using a defensive approach that checks for quotes before removing them:

StrCpy $R1 $R0 1       ; Get first character
StrCmp $R1 '"' +1 +4   ; If it's a quote, remove quotes
StrCpy $R1 $R0 "" 1    ; Skip first quote
StrLen $R2 $R1
IntOp $R2 $R2 - 1      ; Remove last quote
StrCpy $R1 $R1 $R2
Goto +2
StrCpy $R1 $R0         ; No quotes, use path as-is
Suggested change
StrCpy $R1 $R0 "" 1 ; Skip first quote
StrLen $R2 $R1
IntOp $R2 $R2 - 1 ; Remove last quote
StrCpy $R1 $R1 $R2
StrCpy $R1 $R0 1 ; Get first character
StrCmp $R1 '"' +1 +4 ; If it's a quote, remove quotes
StrCpy $R1 $R0 "" 1 ; Skip first quote
StrLen $R2 $R1
IntOp $R2 $R2 - 1 ; Remove last quote
StrCpy $R1 $R1 $R2
Goto +2
StrCpy $R1 $R0 ; No quotes, use path as-is

Copilot uses AI. Check for mistakes.

DetailPrint "Checking if uninstaller exists: $R1"
IfFileExists "$R1" doUninstall cleanupOrphanedRegistry

cleanupOrphanedRegistry:
DetailPrint "Previous uninstaller not found, cleaning up orphaned registry keys..."
SetRegView 64
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The SetRegView 64 call is redundant here as it was already set at line 64 before reading the registry. This line can be removed to avoid unnecessary duplication.

Suggested change
SetRegView 64

Copilot uses AI. Check for mistakes.
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\${EXENAME}.exe"
Goto doInstall

doUninstall:
DetailPrint "Uninstalling previous version..."
Expand Down
Loading