Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UUID String Handling in BLEUuid Class #348

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mankianer
Copy link

This pull request addresses a critical issue in the BLEUuid class where the UUID string was not being properly managed. The class was storing a pointer to the original string passed to it, which could lead to unexpected behavior if the original string was modified or went out of scope.

Changes made:

  1. The _str member of the BLEUuid class has been changed from a const char* to a char*. This allows us to modify the pointer and point it to a new string copy.
  2. In the BLEUuid constructor, we now create a copy of the string passed using the strdup function. This ensures that the BLEUuid class has its own copy of the UUID string, which remains valid even if the original string changes or goes out of scope.
  3. In the BLEUuid destructor, we free the memory allocated for the string copy. This prevents memory leaks when BLEUuid objects are destroyed.

These changes ensure that the BLEUuid class correctly manages its own copy of the UUID string, preventing potential issues caused by changes to the original string. This makes the BLEUuid class more robust and reliable in its handling of UUID strings.

This commit addresses an issue in the BLEUuid class where the UUID string was not being properly copied. Previously, the class stored a pointer to the original string, which could lead to issues if the original string was modified or went out of scope.

The fix involves changing the _str member of the BLEUuid class to be a non-const char pointer, and using the strdup function to create a copy of the string in the BLEUuid constructor. The destructor of the BLEUuid class has also been updated to free the memory allocated for the string copy.

This change ensures that the BLEUuid class has its own copy of the UUID string, preventing potential issues caused by changes to the original string.

Signed-off-by: Mankianer <mankianer@gmail.com>
@CLAassistant
Copy link

CLAassistant commented Feb 1, 2024

CLA assistant check
All committers have signed the CLA.

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants