summaryrefslogtreecommitdiffstats
path: root/src/userpref.c
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2011-03-31 11:43:39 +0200
committerGravatar Martin Szulecki2011-03-31 11:43:39 +0200
commitc5fe346717a449a6bfcdbd7477724d95cdeb85d5 (patch)
treeb2a6c7cf3e8d6aa176962dd7726207e4ecaf81b1 /src/userpref.c
parent430100a50a955fc574f26524ec784b7f39e310b6 (diff)
downloadlibimobiledevice-c5fe346717a449a6bfcdbd7477724d95cdeb85d5.tar.gz
libimobiledevice-c5fe346717a449a6bfcdbd7477724d95cdeb85d5.tar.bz2
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.
Diffstat (limited to 'src/userpref.c')
-rw-r--r--src/userpref.c6
1 files 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;
}