robustness protect and document ensure_user_space 07/3107/1
authorAndy Green <andy.green@linaro.org>
Fri, 15 Feb 2013 14:31:55 +0000 (22:31 +0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 7 Mar 2013 21:01:36 +0000 (13:01 -0800)
Signed-off-by: Andy Green <andy.green@linaro.org>
lib/libwebsockets.c
libwebsockets-api-doc.html

index c553f10..bec14f9 100644 (file)
@@ -2150,9 +2150,17 @@ libwebsocket_get_reserved_bits(struct libwebsocket *wsi)
        return wsi->u.ws.rsv;
 }
 
+/**
+ * libwebsocket_ensure_user_space(): return the user context for the connection if possible
+ * @wsi:       websocket connection instance
+ */
+
 void *
 libwebsocket_ensure_user_space(struct libwebsocket *wsi)
 {
+       if (!wsi->protocol)
+               return NULL;
+
        /* allocate the per-connection user memory (if any) */
 
        if (wsi->protocol->per_session_data_size && !wsi->user_space) {
index b041e74..7fd8702 100644 (file)
@@ -382,6 +382,16 @@ Some apis can act on all live connections of a given protocol,
 this is how you can get a pointer to the active protocol if needed.
 </blockquote>
 <hr>
+<h2>libwebsocket_ensure_user_space - </h2>
+<i>void *</i>
+<b>libwebsocket_ensure_user_space</b>
+(<i>struct libwebsocket *</i> <b>wsi</b>)
+<h3>Arguments</h3>
+<dl>
+<dt><b>wsi</b>
+<dd>websocket connection instance
+</dl>
+<hr>
 <h2>lws_set_log_level - Set the logging bitfield</h2>
 <i>void</i>
 <b>lws_set_log_level</b>