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:
parent
67e3fff047
commit
b2a1a48561
|
@ -1,5 +1,5 @@
|
||||||
# Copyright 2018 Nordic Semiconductor ASA
|
# Copyright 2018 Nordic Semiconductor ASA
|
||||||
# Copyright 2017 Linaro Limited
|
# Copyright 2017-2020 Linaro Limited
|
||||||
# Copyright 2019-2020 Arm Limited
|
# Copyright 2019-2020 Arm Limited
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -327,7 +327,7 @@ class Image():
|
||||||
dependencies_num = len(dependencies[DEP_IMAGES_KEY])
|
dependencies_num = len(dependencies[DEP_IMAGES_KEY])
|
||||||
protected_tlv_size += (dependencies_num * 16)
|
protected_tlv_size += (dependencies_num * 16)
|
||||||
|
|
||||||
if custom_tlvs:
|
if custom_tlvs is not None:
|
||||||
for value in custom_tlvs.values():
|
for value in custom_tlvs.values():
|
||||||
protected_tlv_size += TLV_SIZE + len(value)
|
protected_tlv_size += TLV_SIZE + len(value)
|
||||||
|
|
||||||
|
@ -375,8 +375,9 @@ class Image():
|
||||||
)
|
)
|
||||||
prot_tlv.add('DEPENDENCY', payload)
|
prot_tlv.add('DEPENDENCY', payload)
|
||||||
|
|
||||||
for tag, value in custom_tlvs.items():
|
if custom_tlvs is not None:
|
||||||
prot_tlv.add(tag, value)
|
for tag, value in custom_tlvs.items():
|
||||||
|
prot_tlv.add(tag, value)
|
||||||
|
|
||||||
protected_tlv_off = len(self.payload)
|
protected_tlv_off = len(self.payload)
|
||||||
self.payload += prot_tlv.get()
|
self.payload += prot_tlv.get()
|
||||||
|
|
Loading…
Reference in New Issue