imgtool: Fix 'custom_tlvs' argument handling

When Image.create() is called without the 'custom_tlvs' argument, it
gets its default value (None). It must be checked before performing
any operations on/with it.

Change-Id: I8e0755265f35f9eeb796fe078a6ad8c8d9f2b8da
Signed-off-by: David Vincze <david.vincze@linaro.org>
This commit is contained in:
David Vincze 2020-09-18 11:54:30 +02:00 committed by Andrzej Puzdrowski
parent 67e3fff047
commit b2a1a48561
1 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# Copyright 2018 Nordic Semiconductor ASA
# Copyright 2017 Linaro Limited
# Copyright 2017-2020 Linaro Limited
# Copyright 2019-2020 Arm Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
@ -327,7 +327,7 @@ class Image():
dependencies_num = len(dependencies[DEP_IMAGES_KEY])
protected_tlv_size += (dependencies_num * 16)
if custom_tlvs:
if custom_tlvs is not None:
for value in custom_tlvs.values():
protected_tlv_size += TLV_SIZE + len(value)
@ -375,6 +375,7 @@ class Image():
)
prot_tlv.add('DEPENDENCY', payload)
if custom_tlvs is not None:
for tag, value in custom_tlvs.items():
prot_tlv.add(tag, value)