summaryrefslogtreecommitdiff
path: root/lib/str.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-11-11 18:31:37 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-11-14 13:34:55 +0100
commitfbff0603ad46370ab1a3ecb985d5865b9e3c796e (patch)
treedeb08fcfaaeac5fab8a4cbf97d9c6b27c318a2e4 /lib/str.c
parent0b1140a58ddf70ee1052e77df3743bc1f9f6991a (diff)
downloadgnutls-fbff0603ad46370ab1a3ecb985d5865b9e3c796e.tar.gz
cleanups in _gnutls_buffer_to_datum()
Diffstat (limited to 'lib/str.c')
-rw-r--r--lib/str.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/str.c b/lib/str.c
index b76296a075..2893c32c2c 100644
--- a/lib/str.c
+++ b/lib/str.c
@@ -254,14 +254,15 @@ int _gnutls_buffer_to_datum(gnutls_buffer_st * str, gnutls_datum_t * data, unsig
if (str->length == 0) {
data->data = NULL;
data->size = 0;
- _gnutls_buffer_clear(str);
- return 0;
+ ret = 0;
+ goto fail;
}
if (is_str) {
ret = _gnutls_buffer_append_data(str, "\x00", 1);
if (ret < 0) {
- return gnutls_assert_val(ret);
+ gnutls_assert();
+ goto fail;
}
}
@@ -269,8 +270,8 @@ int _gnutls_buffer_to_datum(gnutls_buffer_st * str, gnutls_datum_t * data, unsig
data->data = gnutls_malloc(str->length);
if (data->data == NULL) {
gnutls_assert();
- _gnutls_buffer_clear(str);
- return GNUTLS_E_MEMORY_ERROR;
+ ret = GNUTLS_E_MEMORY_ERROR;
+ goto fail;
}
memcpy(data->data, str->data, str->length);
data->size = str->length;
@@ -286,6 +287,9 @@ int _gnutls_buffer_to_datum(gnutls_buffer_st * str, gnutls_datum_t * data, unsig
}
return 0;
+ fail:
+ _gnutls_buffer_clear(str);
+ return ret;
}
/* returns data from a string in a constant buffer.