Skip to content

libqcdm/commands: Fix null pointer dereference risks in memory allocation#28

Open
wxmzy88 wants to merge 1 commit into
linux-mobile-broadband:mainfrom
wxmzy88:main
Open

libqcdm/commands: Fix null pointer dereference risks in memory allocation#28
wxmzy88 wants to merge 1 commit into
linux-mobile-broadband:mainfrom
wxmzy88:main

Conversation

@wxmzy88
Copy link
Copy Markdown

@wxmzy88 wxmzy88 commented May 26, 2026

Problem:
Two potential null pointer dereference issues exist in code:
1)Direct access to array pointer without checking malloc return value in log_config_get_set_result
2)Access struct member directly without validating calloc result in qcdm_cmd_log_config_new

Solution:
Add NULL check after malloc allocation, return unified error code QCDM_ERROR_RESPONSE_FAILED when memory allocation fails, release created resource before return. Use internal macro qcdm_return_val_if_fail to verify calloc pointer validity, return 0 as failure result conforming existing code style.

…tion

Problem:
Two potential null pointer dereference issues exist in code:
1)Direct access to array pointer without checking malloc return value in log_config_get_set_result
2)Access struct member directly without validating calloc result in qcdm_cmd_log_config_new
Solution:
Add NULL check after malloc allocation, return unified error code QCDM_ERROR_RESPONSE_FAILED when memory allocation fails, release created resource before return.
Use internal macro qcdm_return_val_if_fail to verify calloc pointer validity, return 0 as failure result conforming existing code style.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant