]> sigrok.org Git - libsigrok.git/commitdiff
sr_session_new(): Return SR_ERR_ARG upon invalid argument.
authorUwe Hermann <redacted>
Mon, 11 Aug 2014 11:15:43 +0000 (13:15 +0200)
committerUwe Hermann <redacted>
Mon, 11 Aug 2014 11:15:43 +0000 (13:15 +0200)
(instead of segfaulting)

src/session.c

index 504af479d4b2d3cce6b0a34de39993dee172bfd3..148da24b0e59fe788ea34e5b72606bfc1198677c 100644 (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;