Index: gnutls-3.0.3/lib/gnutls_session.c =================================================================== --- gnutls-3.0.3.orig/lib/gnutls_session.c +++ gnutls-3.0.3/lib/gnutls_session.c @@ -63,13 +63,14 @@ gnutls_session_get_data (gnutls_session_ gnutls_assert (); return ret; } - *session_data_size = psession.size; if (psession.size > *session_data_size) { + *session_data_size = psession.size; ret = GNUTLS_E_SHORT_MEMORY_BUFFER; goto error; } + *session_data_size = psession.size; if (session_data != NULL) memcpy (session_data, psession.data, psession.size);