From 1e13d7d1420ba8353d8056a5dccaa76cbd3f9ac5 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Thu, 31 Mar 2011 11:43:39 +0200 Subject: userpref: Fix a segfault that might occour if locally stored certs could not be read userpref_get_file_contents() was stil attempting to set the data and size properties on the passed gnutls_datum_t even if g_file_get_contents() failed. This shoud fix a possible segfault in any code code using the pairing. --- src/userpref.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/userpref.c b/src/userpref.c index 6e62000..4aab67b 100644 --- a/src/userpref.c +++ b/src/userpref.c @@ -328,8 +328,10 @@ static int userpref_get_file_contents(const char *file, gnutls_datum_t * data) g_free(filepath); /* Add it to the gnutls_datnum_t structure */ - data->data = (uint8_t*) content; - data->size = size; + if (success) { + data->data = (uint8_t*) content; + data->size = size; + } return success; } -- cgit v1.1-32-gdbae