web_server/wsgi: Don't segfault when wsgi app doesn't return iterable.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 22 Nov 2012 00:46:55 +0000 (00:46 +0000)
committerMatthieu Patou <mat@matws.net>
Thu, 22 Nov 2012 22:56:59 +0000 (14:56 -0800)
There is a bug in the application if this happens, but invalid Python
code shouldn't cause segfaults.

Reviewed-by: Matthieu Patou <mat@matws.net>
source4/web_server/wsgi.c

index 37ded294801d5caee4b1dbd3a2c2af623c0e6964..3f8141c5e2090e923dfe5d95af79e8991cc75c97 100644 (file)
@@ -369,6 +369,11 @@ static void wsgi_process_http_input(struct web_server_data *wdata,
        iter = PyObject_GetIter(result);
        Py_DECREF(result);
 
+       if (iter == NULL) {
+               DEBUG(0, ("wsgi application did not return iterable\n"));
+               return;
+       }
+
        /* Now, iter over all the data returned */
 
        while ((item = PyIter_Next(iter))) {