null exception with null extensions list
authorAndrew Chambers <andrewchamberss@gmail.com>
Sun, 20 May 2012 00:17:09 +0000 (08:17 +0800)
committerAndy Green <andy.green@linaro.org>
Sun, 20 May 2012 00:17:09 +0000 (08:17 +0800)
I was under the impression extensions could be null, so heres a patch to fix this error in libwebsockets. Cheers!

Signed-off-by: Andrew Chambers <andrewchamberss@gmail.com>
--

lib/libwebsockets.c

index 5a28f30..4b5ec8b 100644 (file)
@@ -2946,11 +2946,14 @@ libwebsocket_create_context(int port, const char *interf,
        m = LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT;
        if (port)
                m = LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT;
-       while (extensions->callback) {
-               debug("  Extension: %s\n", extensions->name);
-               extensions->callback(context, extensions,
-                                                       NULL, m, NULL, NULL, 0);
-               extensions++;
+       
+       if (extensions) {
+           while (extensions->callback) {
+                   debug("  Extension: %s\n", extensions->name);
+                   extensions->callback(context, extensions,
+                                               NULL, m, NULL, NULL, 0);
+                   extensions++;
+           }
        }
 
        return context;