-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix memory leaks related to PTPCanon_changes_entry.u.info (#1009)
* fix memory leaks related to PTPCanon_changes_entry.u.info Unpacking canon EOS event data uses heap memory stored in `char *info` for different types of information (mostly PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN but also PTP_CANON_EOS_CHANGES_TYPE_FOCUS*). This memory needs to be freed on every call-sight of ptp_get_one_eos_event, which it wasn't and it needs to do so for every type using it, but if at all, it only freed it for PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN data. This patch replaces `char *info` with `char info[84]` and introduces a macro called PTP_CANON_SET_INFO() for setting that data. 84 is used, because the union is at least that large anyway because of the `object` member and 84 is sufficient for all current use cases. The macro makes sure there is no buffer overflow in the future. This change does away with the error prone task of freeing the `info` memory after every ptp_get_one_eos_event() call. * fix CodeQL complaint about return value check of sscanf --------- Co-authored-by: axxel <awagger@web.de>
- Loading branch information
Showing
3 changed files
with
36 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters