From 1de2f9ab5c16f9e260817dd3dcf64ef4b1ba3215 Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Mon, 11 Dec 2023 11:04:29 +0100 Subject: [PATCH] Initialize all variables that could be unassigned Due to the convoluted logic of the edit() function, multiple variables may be referenced before proper assignment unless they are given a value of `None` first. Unfortunately, at least two such variables were potentially referenced without being initialized first (among other things, causing the crash mentioned in #2783). This ensures all variables that may remain "unassigned" are initialized to `None` at the start of the function. --- python/nav/web/maintenance/views.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/python/nav/web/maintenance/views.py b/python/nav/web/maintenance/views.py index 7d4d653e9f..9eab84a44b 100644 --- a/python/nav/web/maintenance/views.py +++ b/python/nav/web/maintenance/views.py @@ -252,9 +252,7 @@ def cancel(request, task_id): def edit(request, task_id=None, start_time=None, **_): account = get_account(request) quickselect = QuickSelect(service=True) - component_trail = None - component_keys = None - task = None + component_trail = component_keys_errors = component_data = task = None if task_id: task = get_object_or_404(MaintenanceTask, pk=task_id)