Fix UUID generation error handling in switch_utils.c

Ensure that invalid UUID generation scenarios are correctly handled by checking the return status of `switch_uuid_generate_version`. This prevents potential incorrect formatting or uninitialized usage.
This commit is contained in:
Aron Podrigal 2025-01-15 16:51:28 -06:00
parent 323e907011
commit 575e9bfcff
1 changed files with 2 additions and 1 deletions

View File

@ -4116,8 +4116,9 @@ SWITCH_DECLARE(char *) switch_uuid_str_version(char *buf, switch_size_t len, int
if (len < (SWITCH_UUID_FORMATTED_LENGTH + 1)) { if (len < (SWITCH_UUID_FORMATTED_LENGTH + 1)) {
switch_snprintf(buf, len, "INVALID"); switch_snprintf(buf, len, "INVALID");
} else if (switch_uuid_generate_version(&uuid, version) != SWITCH_STATUS_SUCCESS) {
switch_snprintf(buf, len, "INVALID");
} else { } else {
switch_uuid_generate_version(&uuid, version);
switch_uuid_format(buf, &uuid); switch_uuid_format(buf, &uuid);
} }