Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

xfreerdp: fix multiple memory leaks detected by valgrind

  • Loading branch information...
commit 32a54130e7fb4d5150e1a0edf76e00f2f712cbc8 1 parent 7a53ce4
@awakecoding awakecoding authored
View
2  client/X11/xfreerdp.c
@@ -1131,6 +1131,8 @@ int xfreerdp_run(freerdp* instance)
gdi_free(instance);
xf_free(xfi);
+ freerdp_context_free(instance);
+
freerdp_free(instance);
return ret;
View
39 libfreerdp-crypto/tls.c
@@ -282,13 +282,14 @@ boolean tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname)
{
int match;
int index;
- char* common_name;
- int common_name_length;
- char** alt_names;
- int alt_names_count;
- int* alt_names_lengths;
+ char* common_name = NULL;
+ int common_name_length = 0;
+ char** alt_names = NULL;
+ int alt_names_count = 0;
+ int* alt_names_lengths = NULL;
boolean certificate_status;
boolean hostname_match = false;
+ boolean verification_status = false;
rdpCertificateData* certificate_data;
/* ignore certificate verification if user explicitly required it (discouraged) */
@@ -336,7 +337,12 @@ boolean tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname)
/* if the certificate is valid and the certificate name matches, verification succeeds */
if (certificate_status && hostname_match)
- return true; /* success! */
+ {
+ if (common_name)
+ xfree(common_name);
+
+ verification_status = true; /* success! */
+ }
/* if the certificate is valid but the certificate name does not match, warn user, do not accept */
if (certificate_status && !hostname_match)
@@ -350,7 +356,6 @@ boolean tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname)
char* subject;
char* fingerprint;
boolean accept_certificate = false;
- boolean verification_status = false;
issuer = crypto_cert_issuer(cert->px509);
subject = crypto_cert_subject(cert->px509);
@@ -397,11 +402,27 @@ boolean tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname)
xfree(issuer);
xfree(subject);
xfree(fingerprint);
+ }
+
+ if (common_name)
+ xfree(common_name);
- return verification_status;
+ if (alt_names)
+ {
+ for (index = 0; index < alt_names_count; index++)
+ xfree(alt_names[index]);
+
+ xfree(alt_names);
+ }
+
+ if (certificate_data)
+ {
+ xfree(certificate_data->fingerprint);
+ xfree(certificate_data->hostname);
+ xfree(certificate_data);
}
- return false;
+ return verification_status;
}
void tls_print_certificate_error(char* hostname, char* fingerprint)
View
2  libfreerdp-locale/keyboard_xkb.c
@@ -338,6 +338,8 @@ uint32 freerdp_keyboard_init_xkb(uint32 keyboardLayoutId)
freerdp_keyboard_load_map_from_xkb(display);
+ XCloseDisplay(display);
+
return keyboardLayoutId;
}
View
15 libfreerdp-utils/file.c
@@ -90,17 +90,16 @@ char* freerdp_get_home_path(rdpSettings* settings)
char* freerdp_get_config_path(rdpSettings* settings)
{
- char* path;
-
- path = (char*) xmalloc(strlen(settings->home_path) + sizeof(FREERDP_CONFIG_DIR) + 2);
- sprintf(path, "%s/%s", settings->home_path, FREERDP_CONFIG_DIR);
+ if (settings->config_path != NULL)
+ return settings->config_path;
- if (!freerdp_check_file_exists(path))
- freerdp_mkdir(path);
+ settings->config_path = (char*) xmalloc(strlen(settings->home_path) + sizeof(FREERDP_CONFIG_DIR) + 2);
+ sprintf(settings->config_path, "%s/%s", settings->home_path, FREERDP_CONFIG_DIR);
- settings->config_path = path;
+ if (!freerdp_check_file_exists(settings->config_path))
+ freerdp_mkdir(settings->config_path);
- return path;
+ return settings->config_path;
}
char* freerdp_get_current_path(rdpSettings* settings)
Please sign in to comment.
Something went wrong with that request. Please try again.