From: Uwe Hermann Date: Mon, 11 Aug 2014 11:15:43 +0000 (+0200) Subject: sr_session_new(): Return SR_ERR_ARG upon invalid argument. X-Git-Tag: libsigrok-0.4.0~1154 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=41de54ffb1d36cbf5021705403a85b171662ec96;p=libsigrok.git sr_session_new(): Return SR_ERR_ARG upon invalid argument. (instead of segfaulting) --- diff --git a/src/session.c b/src/session.c index 504af479..148da24b 100644 --- a/src/session.c +++ b/src/session.c @@ -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;