Fix memory leak in base62_encode()

This commit is contained in:
Martin Lund 2024-10-25 18:26:59 +02:00
parent 7e314b2cc3
commit 330e99381e
3 changed files with 4 additions and 4 deletions

View file

@ -121,10 +121,9 @@ unsigned long djb2_hash(const unsigned char *str)
}
// Function to encode a number to base62
char *base62_encode(unsigned long num)
void *base62_encode(unsigned long num, char *output)
{
const char base62_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
char *output = (char *) malloc(5); // 4 characters + null terminator
if (output == NULL)
{
tio_error_print("Memory allocation failed");