Skip to content

Commit

Permalink
Initialize all variables that could be unassigned
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lunkwill42 committed Dec 11, 2023
1 parent 869a044 commit 1de2f9a
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions python/nav/web/maintenance/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1de2f9a

Please sign in to comment.