Skip to content

Commit

Permalink
Removes uses of OPENSSL_free (#135)
Browse files Browse the repository at this point in the history
since it is simply a macro that adds debug info __FUNC__ and
__LINE__ to a normal free() call.
The code now use free() throughout.

Co-authored-by: bjornvolcker <[email protected]>
  • Loading branch information
bjornvolcker and bjornvolcker authored Apr 9, 2024
1 parent 455298e commit 445a0ac
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 22 deletions.
4 changes: 2 additions & 2 deletions lib/plugins/threaded-signing/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ signature_info_free(signature_info_t *signature_info)
if (!signature_info) return;

free(signature_info->private_key);
if (signature_info->signature) openssl_free(signature_info->signature);
free(signature_info->signature);
free(signature_info->hash);
free(signature_info);
}
Expand Down Expand Up @@ -890,7 +890,7 @@ sv_interface_malloc(size_t data_size)
void
sv_interface_free(uint8_t *data)
{
openssl_free(data);
free(data);
}

/* This plugin initializer expects the |user_data| to be a signature_info_t struct. Only the
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/unthreaded-signing/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ sv_signing_plugin_session_teardown(void *handle)
if (!self) return;

free(self->signature_info.private_key);
if (self->signature_info.signature) openssl_free(self->signature_info.signature);
free(self->signature_info.signature);
free(self);
}

Expand All @@ -204,7 +204,7 @@ sv_interface_malloc(size_t data_size)
void
sv_interface_free(uint8_t *data)
{
openssl_free(data);
free(data);
}

int
Expand Down
10 changes: 0 additions & 10 deletions lib/src/includes/signed_video_openssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ openssl_create_handle(void);
void
openssl_free_handle(void *handle);

/**
* @brief Frees data
*
* Free the allocated data memory.
*
* @param data Pointer to the data.
*/
void
openssl_free(uint8_t *data);

/**
* @brief Hashes data into a 256 bit hash
*
Expand Down
2 changes: 1 addition & 1 deletion lib/src/signed_video_h26x_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ signature_free(signature_info_t *self)
free(self->private_key);
free(self->public_key);
free(self->hash);
sv_interface_free(self->signature);
free(self->signature);
free(self);
}

Expand Down
7 changes: 0 additions & 7 deletions lib/src/signed_video_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ openssl_create_private_key(sign_algo_t algo, const char *path_to_key, key_paths_
#define PRIVATE_RSA_KEY_FILE "private_rsa_key.pem"
#define PRIVATE_ECDSA_KEY_FILE "private_ecdsa_key.pem"

/* Free the data allocated by OpenSSL. */
void
openssl_free(uint8_t *data)
{
OPENSSL_free(data);
}

/* Allocates enough memory for the signature when using the |private_key| in |signature_info|. */
SignedVideoReturnCode
openssl_signature_malloc(signature_info_t *signature_info)
Expand Down

0 comments on commit 445a0ac

Please sign in to comment.