From 6d883f488ff59b2394982b62895d50b1d1d55bf4 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Wed, 3 Jun 2015 19:56:12 -0400 Subject: Return error if file_id parameter is NULL. --- other/apidsl/tox.in.h | 1 + toxcore/tox.c | 5 +++++ toxcore/tox.h | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/other/apidsl/tox.in.h b/other/apidsl/tox.in.h index fc66dfac..30c78e44 100644 --- a/other/apidsl/tox.in.h +++ b/other/apidsl/tox.in.h @@ -1651,6 +1651,7 @@ namespace file { error for get { + NULL, /** * The friend_number passed did not designate a valid friend. */ diff --git a/toxcore/tox.c b/toxcore/tox.c index d3b021aa..3e9db766 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -1011,6 +1011,11 @@ void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *function bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32_t file_number, uint8_t *file_id, TOX_ERR_FILE_GET *error) { + if (!file_id) { + SET_ERROR_PARAMETER(error, TOX_ERR_FILE_GET_NULL); + return 0; + } + const Messenger *m = tox; int ret = file_get_id(m, friend_number, file_number, file_id); diff --git a/toxcore/tox.h b/toxcore/tox.h index e5158915..14c9f616 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -1780,6 +1780,11 @@ typedef enum TOX_ERR_FILE_GET { */ TOX_ERR_FILE_GET_OK, + /** + * One of the arguments to the function was NULL when it was not expected. + */ + TOX_ERR_FILE_GET_NULL, + /** * The friend_number passed did not designate a valid friend. */ -- cgit v1.2.3