Removed reference to strndup.
h3rald h3rald@h3rald.com
Sun, 08 Dec 2024 17:43:17 +0100
1 files changed,
9 insertions(+),
1 deletions(-)
jump to
M
src/hex.c
→
src/hex.c
@@ -2646,7 +2646,15 @@ result = 1;
break; } quotation[i]->type = HEX_TYPE_STRING; - quotation[i]->data.str_value = strndup(&str.data.str_value[i], 1); + quotation[i]->data.str_value = (char *)malloc(2); // Allocate 2 bytes: 1 for the character and 1 for null terminator + if (!quotation[i]->data.str_value) + { + hex_error(ctx, "Memory allocation failed"); + result = 1; + break; + } + quotation[i]->data.str_value[0] = str.data.str_value[i]; // Copy the single character + quotation[i]->data.str_value[1] = '\0'; // Null-terminate the string } if (result == 0) {