Null pointer dereference in several cmd_ functions arose when session had
authorSebastian Hammer <quinn@indexdata.com>
Sat, 6 Jan 2007 05:32:23 +0000 (05:32 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Sat, 6 Jan 2007 05:32:23 +0000 (05:32 +0000)
expired (introduced when status element was added). Bug # 790

src/http_command.c

index 9a14705..086db07 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http_command.c,v 1.7 2007-01-06 04:54:58 quinn Exp $
+ * $Id: http_command.c,v 1.8 2007-01-06 05:32:23 quinn Exp $
  */
 
 #include <stdio.h>
@@ -180,11 +180,13 @@ static void cmd_termlist(struct http_channel *c)
     int len;
     int i;
     char *name = http_argbyname(rq, "name");
-    int status = session_active_clients(s->psession);
+    int status;
 
     if (!s)
         return;
 
+    status = session_active_clients(s->psession);
+
     if (!name)
         name = "subject";
     if (strlen(name) > 255)
@@ -335,11 +337,13 @@ static void cmd_show(struct http_channel *c)
     struct http_response *rs = c->response;
     struct http_session *s = locate_session(rq, rs);
     char *block = http_argbyname(rq, "block");
-    int status = session_active_clients(s->psession);
+    int status;
 
     if (!s)
         return;
 
+    status = session_active_clients(s->psession);
+
     if (block)
     {
         if (status && (!s->psession->reclist || !s->psession->reclist->num_records))
@@ -396,11 +400,12 @@ static void cmd_stat(struct http_channel *c)
     struct http_response *rs = c->response;
     struct http_session *s = locate_session(rq, rs);
     struct statistics stat;
-    int clients = session_active_clients(s->psession);
+    int clients;
 
     if (!s)
         return;
 
+    clients = session_active_clients(s->psession);
     statistics(s->psession, &stat);
 
     wrbuf_rewind(c->wrbuf);