connectedhomeip icon indicating copy to clipboard operation
connectedhomeip copied to clipboard

Add a null-check on the return value of function getXTransitionStateByIndex

Open mugitya03 opened this issue 6 months ago • 6 comments

Summary

The function getXTransitionStateByIndex may return nullptr if index is invalid. Inthe function updateXYCommand, the return value of getXTransitionStateByIndex is directly propagated to the function computeNewColor16uValue, where it is dereferenced without any validation. I think it would be better to add a check on the return value of getXTransitionStateByIndex, as all other call sites have such checks.

Testing

Verified using static analysis and manual review:

  • Identified the issue with a static analyzer and confirmed it through code inspection.
  • Applied this patch and re-ran the analysis, confirming that the bug report no longer appears.

mugitya03 avatar Jul 03 '25 20:07 mugitya03

PR #39848: Size comparison from c4c6beaa35e1199079a599bb41f66cc71e93265d to 5aaedb9f13eaff4fba7035d6afb79bb4d96209ad

Full report (2 builds for cc32xx)
platform target config section c4c6beaa 5aaedb9f change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 549470 549470 0 0.0
RAM 205144 205144 0 0.0
lock CC3235SF_LAUNCHXL FLASH 582590 582590 0 0.0
RAM 205344 205344 0 0.0

github-actions[bot] avatar Jul 03 '25 20:07 github-actions[bot]

Sorry, I may have mistakenly applied a Copilot suggestion while editing this code. Now it has been fixed.

mugitya03 avatar Jul 11 '25 20:07 mugitya03

PR #39848: Size comparison from 3e1a974ce250e63eb830d05df652c9f454ecc3e1 to 3357a97af844a93308e2fc21f872b054df54bc89

Full report (59 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 3e1a974c 3357a97a change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1102628 1102628 0 0.0
RAM 178970 178970 0 0.0
bl702 lighting-app bl702+eth FLASH 656030 656030 0 0.0
RAM 134929 134929 0 0.0
bl702+wifi FLASH 833218 833218 0 0.0
RAM 124469 124469 0 0.0
bl706+mfd+rpc+littlefs FLASH 1065336 1065336 0 0.0
RAM 117341 117341 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 894882 894882 0 0.0
RAM 105628 105628 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 978600 978600 0 0.0
RAM 109820 109820 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 763080 763080 0 0.0
RAM 103328 103328 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 774620 774620 0 0.0
RAM 108496 108496 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 720960 720960 0 0.0
RAM 96900 96900 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 705252 705252 0 0.0
RAM 97108 97108 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 548818 548818 0 0.0
RAM 205104 205104 0 0.0
lock CC3235SF_LAUNCHXL FLASH 581794 581794 0 0.0
RAM 205304 205304 0 0.0
efr32 lock-app BRD4187C FLASH 954984 954984 0 0.0
RAM 126532 126532 0 0.0
BRD4338a FLASH 749388 749380 -8 -0.0
RAM 251880 251880 0 0.0
window-app BRD4187C FLASH 1049512 1049512 0 0.0
RAM 122728 122728 0 0.0
esp32 all-clusters-app c3devkit DRAM 102232 102232 0 0.0
FLASH 1780566 1780574 8 0.0
IRAM 83862 83862 0 0.0
m5stack DRAM 121116 121116 0 0.0
FLASH 1747870 1747858 -12 -0.0
IRAM 117071 117071 0 0.0
linux air-purifier-app debug unknown 4856 4856 0 0.0
FLASH 2793704 2793704 0 0.0
RAM 117192 117192 0 0.0
all-clusters-app debug unknown 5672 5672 0 0.0
FLASH 6195744 6195766 22 0.0
RAM 532016 532016 0 0.0
all-clusters-minimal-app debug unknown 5536 5536 0 0.0
FLASH 5470648 5470670 22 0.0
RAM 227848 227848 0 0.0
bridge-app debug unknown 5568 5568 0 0.0
FLASH 4804860 4804860 0 0.0
RAM 207552 207552 0 0.0
camera-app debug unknown 8976 8976 0 0.0
FLASH 6945307 6945307 0 0.0
RAM 230592 230592 0 0.0
camera-controller debug unknown 9216 9216 0 0.0
FLASH 14388171 14388171 0 0.0
RAM 662456 662456 0 0.0
chip-tool debug unknown 6272 6272 0 0.0
FLASH 14760385 14760385 0 0.0
RAM 656096 656096 0 0.0
chip-tool-ipv6only arm64 unknown 40736 40736 0 0.0
FLASH 12730631 12730631 0 0.0
RAM 702360 702360 0 0.0
closure-app debug unknown 5536 5536 0 0.0
FLASH 4787716 4787716 0 0.0
RAM 200424 200424 0 0.0
fabric-admin debug unknown 5952 5952 0 0.0
FLASH 12803205 12803205 0 0.0
RAM 655128 655128 0 0.0
fabric-bridge-app debug unknown 4816 4816 0 0.0
FLASH 4590190 4590190 0 0.0
RAM 193264 193264 0 0.0
fabric-sync debug unknown 5064 5064 0 0.0
FLASH 5738957 5738957 0 0.0
RAM 492528 492528 0 0.0
lighting-app debug+rpc+ui unknown 6280 6280 0 0.0
FLASH 5691649 5691681 32 0.0
RAM 209816 209816 0 0.0
lock-app debug unknown 5496 5496 0 0.0
FLASH 4833572 4833572 0 0.0
RAM 197032 197032 0 0.0
ota-provider-app debug unknown 4856 4856 0 0.0
FLASH 4444046 4444046 0 0.0
RAM 185952 185952 0 0.0
ota-requestor-app debug unknown 4736 4736 0 0.0
FLASH 4516210 4516210 0 0.0
RAM 188824 188824 0 0.0
shell debug unknown 4288 4288 0 0.0
FLASH 3073436 3073468 32 0.0
RAM 147184 147184 0 0.0
thermostat-no-ble arm64 unknown 9832 9832 0 0.0
FLASH 4233599 4233599 0 0.0
RAM 233192 233192 0 0.0
tv-app debug unknown 5832 5832 0 0.0
FLASH 6103805 6103805 0 0.0
RAM 616808 616808 0 0.0
tv-casting-app debug unknown 5352 5352 0 0.0
FLASH 12906653 12906653 0 0.0
RAM 772592 772592 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 888064 888056 -8 -0.0
RAM 166122 166122 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 897204 897196 -8 -0.0
RAM 145060 145060 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 858388 858380 -8 -0.0
RAM 141014 141014 0 0.0
nxp contact mcxw71+release FLASH 624744 624744 0 0.0
RAM 63132 63132 0 0.0
lock mcxw71+release FLASH 775952 775952 0 0.0
RAM 67788 67788 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1632452 1632468 16 0.0
RAM 211064 211064 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1576644 1576644 0 0.0
RAM 208432 208432 0 0.0
light cy8ckit_062s2_43012 FLASH 1449436 1449436 0 0.0
RAM 197152 197152 0 0.0
lock cy8ckit_062s2_43012 FLASH 1481692 1481692 0 0.0
RAM 224872 224872 0 0.0
qpg lighting-app qpg6200+debug FLASH 744184 744168 -16 -0.0
RAM 94252 94252 0 0.0
lock-app qpg6200+debug FLASH 753804 753804 0 0.0
RAM 94280 94280 0 0.0
stm32 light STM32WB5MM-DK FLASH 465236 465228 -8 -0.0
RAM 141336 141336 0 0.0
telink bridge-app tl7218x FLASH 702278 702278 0 0.0
RAM 93564 93564 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 794006 794014 8 0.0
RAM 43980 43980 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 782412 782420 8 0.0
RAM 100876 100876 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 709528 709528 0 0.0
RAM 54204 54204 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 746122 746122 0 0.0
RAM 77368 77368 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 722848 722848 0 0.0
RAM 36960 36960 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602948 602956 8 0.0
RAM 112496 112496 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 817966 817978 12 0.0
RAM 99128 99128 0 0.0
tizen all-clusters-app arm unknown 5096 5096 0 0.0
FLASH 1695632 1695664 32 0.0
RAM 91404 91404 0 0.0
chip-tool-ubsan arm unknown 20800 20800 0 0.0
FLASH 21098370 21098370 0 0.0
RAM 9178412 9178412 0 0.0

github-actions[bot] avatar Jul 14 '25 14:07 github-actions[bot]

PR #39848: Size comparison from e3e5a51c77a3e9cce7351b3cca4b29f303e365b1 to 56509600344599d80447034e15bbc96061247042

Full report (57 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section e3e5a51c 56509600 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1103442 1103186 -256 -0.0
RAM 178970 178970 0 0.0
bl702 lighting-app bl702+eth FLASH 656360 656360 0 0.0
RAM 134929 134929 0 0.0
bl702+wifi FLASH 833964 833964 0 0.0
RAM 124469 124469 0 0.0
bl706+mfd+rpc+littlefs FLASH 1065986 1065986 0 0.0
RAM 117341 117341 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 895208 895208 0 0.0
RAM 105628 105628 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 978926 978926 0 0.0
RAM 109820 109820 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 765432 765432 0 0.0
RAM 103336 103336 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 776972 776972 0 0.0
RAM 108504 108504 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 723280 723280 0 0.0
RAM 96908 96908 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 707572 707572 0 0.0
RAM 97116 97116 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 549714 549714 0 0.0
RAM 205104 205104 0 0.0
lock CC3235SF_LAUNCHXL FLASH 582162 582162 0 0.0
RAM 205304 205304 0 0.0
efr32 lock-app BRD4187C FLASH 957176 957176 0 0.0
RAM 126532 126532 0 0.0
BRD4338a FLASH 751524 751524 0 0.0
RAM 251880 251880 0 0.0
window-app BRD4187C FLASH 1049848 1049840 -8 -0.0
RAM 122728 122728 0 0.0
esp32 all-clusters-app c3devkit DRAM 102232 102232 0 0.0
FLASH 1781786 1781794 8 0.0
IRAM 83862 83862 0 0.0
m5stack DRAM 121116 121116 0 0.0
FLASH 1748966 1748954 -12 -0.0
IRAM 117071 117071 0 0.0
linux air-purifier-app debug unknown 4864 4864 0 0.0
FLASH 2799454 2799454 0 0.0
RAM 117192 117192 0 0.0
all-clusters-app debug unknown 5680 5680 0 0.0
FLASH 6208576 6208598 22 0.0
RAM 532480 532480 0 0.0
all-clusters-minimal-app debug unknown 5544 5544 0 0.0
FLASH 5476410 5476432 22 0.0
RAM 227768 227768 0 0.0
bridge-app debug unknown 5576 5576 0 0.0
FLASH 4804828 4804828 0 0.0
RAM 207456 207456 0 0.0
camera-app debug unknown 8984 8984 0 0.0
FLASH 6945387 6945387 0 0.0
RAM 230496 230496 0 0.0
camera-controller debug unknown 9216 9216 0 0.0
FLASH 14390123 14390123 0 0.0
RAM 662680 662680 0 0.0
chip-tool debug unknown 6272 6272 0 0.0
FLASH 14761263 14761263 0 0.0
RAM 656224 656224 0 0.0
chip-tool-ipv6only arm64 unknown 40744 40744 0 0.0
FLASH 12730327 12730327 0 0.0
RAM 702488 702488 0 0.0
closure-app debug unknown 5544 5544 0 0.0
FLASH 4787714 4787714 0 0.0
RAM 200344 200344 0 0.0
fabric-admin debug unknown 5952 5952 0 0.0
FLASH 12803621 12803621 0 0.0
RAM 655256 655256 0 0.0
fabric-bridge-app debug unknown 4824 4824 0 0.0
FLASH 4589576 4589576 0 0.0
RAM 193200 193200 0 0.0
fabric-sync debug unknown 5064 5064 0 0.0
FLASH 5738157 5738157 0 0.0
RAM 492576 492576 0 0.0
lighting-app debug+rpc+ui unknown 6288 6288 0 0.0
FLASH 5691553 5691585 32 0.0
RAM 209720 209720 0 0.0
lock-app debug unknown 5504 5504 0 0.0
FLASH 4834240 4834240 0 0.0
RAM 196936 196936 0 0.0
ota-provider-app debug unknown 4864 4864 0 0.0
FLASH 4443754 4443754 0 0.0
RAM 185952 185952 0 0.0
ota-requestor-app debug unknown 4744 4744 0 0.0
FLASH 4515958 4515958 0 0.0
RAM 188824 188824 0 0.0
shell debug unknown 4288 4288 0 0.0
FLASH 3078404 3078420 16 0.0
RAM 147088 147088 0 0.0
thermostat-no-ble arm64 unknown 9840 9840 0 0.0
FLASH 4247871 4247871 0 0.0
RAM 233632 233632 0 0.0
tv-app debug unknown 5832 5832 0 0.0
FLASH 6103677 6103677 0 0.0
RAM 616856 616856 0 0.0
tv-casting-app debug unknown 5352 5352 0 0.0
FLASH 12907357 12907357 0 0.0
RAM 772592 772592 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 890936 890928 -8 -0.0
RAM 152731 152731 0 0.0
nxp contact mcxw71+release FLASH 626560 626560 0 0.0
RAM 64020 64020 0 0.0
lock mcxw71+release FLASH 778088 778088 0 0.0
RAM 68676 68676 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1633652 1633668 16 0.0
RAM 211064 211064 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1577828 1577844 16 0.0
RAM 208432 208432 0 0.0
light cy8ckit_062s2_43012 FLASH 1449772 1449772 0 0.0
RAM 197152 197152 0 0.0
lock cy8ckit_062s2_43012 FLASH 1482044 1482044 0 0.0
RAM 224872 224872 0 0.0
qpg lighting-app qpg6200+debug FLASH 768792 768776 -16 -0.0
RAM 97620 97620 0 0.0
lock-app qpg6200+debug FLASH 755156 755156 0 0.0
RAM 94404 94404 0 0.0
stm32 light STM32WB5MM-DK FLASH 465636 465628 -8 -0.0
RAM 141336 141336 0 0.0
telink bridge-app tl7218x FLASH 702726 702726 0 0.0
RAM 93564 93564 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 794630 794638 8 0.0
RAM 43980 43980 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 783036 783044 8 0.0
RAM 100876 100876 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 710152 710152 0 0.0
RAM 54204 54204 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 746746 746746 0 0.0
RAM 77368 77368 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 723472 723472 0 0.0
RAM 36960 36960 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 603902 603910 8 0.0
RAM 112532 112532 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 818640 818652 12 0.0
RAM 99128 99128 0 0.0
tizen all-clusters-app arm unknown 5096 5096 0 0.0
FLASH 1698072 1698096 24 0.0
RAM 91360 91360 0 0.0
chip-tool-ubsan arm unknown 20804 20804 0 0.0
FLASH 21100626 21100626 0 0.0
RAM 9177580 9177580 0 0.0

github-actions[bot] avatar Jul 18 '25 00:07 github-actions[bot]

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 3 committers have signed the CLA.

:white_check_mark: andy31415
:x: jinyaoguo
:x: mugitya03
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Nov 25 '25 15:11 CLAassistant

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 3 committers have signed the CLA.

:x: jinyaoguo
:x: mugitya03
:x: andy31415
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Nov 25 '25 15:11 CLAassistant