Fixed segfault if chip was not found in chip config files #1166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
stlink_chipid_get_params()
used to segfault onmemcmp()
whenstruct stlink_chipid_params *params
wasNULL
. This could happen if either:*.chip
), orprocess_chipfile()
failed to parsechip_id
from the chip config files.The latter case is caused by the usage of
atoi()
to parse the chip id. Since the chip id is stored in hex,atoi()
returns 0; such id cannot be matched to any actual chip.The segfault occurs in:
stlink/src/stlink-lib/chipid.c
Line 957 in a52e1bc
Check if
params
isNULL
, in such case, set it top2
, which should not beNULL
as long asstruct stlink_chipid_params devices[]
exists.May fix (workaround) #1163.