sr_session_new(): Return SR_ERR_ARG upon invalid argument.

(instead of segfaulting)
This commit is contained in:
Uwe Hermann 2014-08-11 13:15:43 +02:00
parent 4172352914
commit 41de54ffb1
1 changed files with 4 additions and 1 deletions

View File

@ -67,7 +67,7 @@ struct datafeed_callback {
* is undefined and should not be used. Must not be NULL.
*
* @retval SR_OK Success.
* @retval SR_ERR_BUG A session exists already.
* @retval SR_ERR_ARG Invalid argument.
*
* @since 0.4.0
*/
@ -75,6 +75,9 @@ SR_API int sr_session_new(struct sr_session **new_session)
{
struct sr_session *session;
if (!new_session)
return SR_ERR_ARG;
session = g_malloc0(sizeof(struct sr_session));
session->source_timeout = -1;