fix valgrind problems

This commit is contained in:
josch
2014-10-19 08:58:56 +02:00
parent f23250aaef
commit 5a673abd1b
3 changed files with 67 additions and 7 deletions

View File

@@ -156,6 +156,10 @@ const char *mfconn_create_call_signature(mfconn * conn, const char *url,
signature_raw = strdup_printf("%d%s%s%s",
(conn->secret_key % 256),
conn->secret_time, api, args);
if (signature_raw == NULL) {
fprintf(stderr, "strdup_printf failed\n");
return NULL;
}
MD5((const unsigned char *)signature_raw,
strlen(signature_raw), signature_enc);
@@ -239,6 +243,11 @@ const char *mfconn_create_signed_get(mfconn * conn, int ssl,
// append api GET args to api request
api_request = (char *)realloc(api_request, bytes_to_alloc);
if (api_request == NULL) {
fprintf(stderr, "cannot allocate memory\n");
return NULL;
}
strncat(api_request, api_args, api_args_len);
strcat(api_request, signature);

View File

@@ -42,6 +42,10 @@ char *strdup_printf(char *fmt, ...)
bytes_to_allocate++;
ret_str = (char *)malloc(bytes_to_allocate * sizeof(char));
if (ret_str == NULL) {
fprintf(stderr, "failed to allocate memory\n");
return NULL;
}
va_start(ap, fmt);
bytes_to_allocate = vsnprintf(ret_str, bytes_to_allocate, fmt, ap);

View File

@@ -58,11 +58,58 @@
...
fun:curl_multi_perform
fun:curl_easy_perform
fun:http_post_buf
fun:mfconn_api_user_get_session_token
fun:mfconn_create
fun:mfshell_cmd_auth
fun:mfshell_exec
fun:mfshell_parse_commands
fun:main
...
}
{
libcurl #1
Memcheck:Leak
...
fun:curl_global_init
fun:curl_easy_init
...
}
{
libcurl #2
Memcheck:Cond
...
fun:curl_multi_perform
fun:curl_easy_perform
...
}
{
libcurl #3
Memcheck:Value8
fun:Curl_raw_toupper
...
}
{
libcrypto
Memcheck:Leak
...
fun:curl_multi_perform
fun:curl_easy_perform
...
}
{
openssl
Memcheck:Leak
fun:malloc
fun:CRYPTO_malloc
...
fun:ssl_verify_cert_chain
...
}
{
jansson #1
Memcheck:Cond
...
obj:*/libjansson.so*
...
}
{
jansson #2
Memcheck:Value8
...
obj:*/libjansson.so*
...
}