Author: jra
Date: 2006-06-20 01:25:27 +0000 (Tue, 20 Jun 2006)
New Revision: 16391

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16391

Log:
Klockwork #1168. Protect against null deref.
Jeremy.

Modified:
   trunk/source/printing/printing_db.c


Changeset:
Modified: trunk/source/printing/printing_db.c
===================================================================
--- trunk/source/printing/printing_db.c 2006-06-20 01:20:38 UTC (rev 16390)
+++ trunk/source/printing/printing_db.c 2006-06-20 01:25:27 UTC (rev 16391)
@@ -55,7 +55,9 @@
        /* Not found. */
        if (num_open >= MAX_PRINT_DBS_OPEN) {
                /* Try and recycle the last entry. */
-               DLIST_PROMOTE(print_db_head, last_entry);
+               if (print_db_head && last_entry) {
+                       DLIST_PROMOTE(print_db_head, last_entry);
+               }
 
                for (p = print_db_head; p; p = p->next) {
                        if (p->ref_count)
@@ -72,7 +74,7 @@
                        memset(p->printer_name, '\0', sizeof(p->printer_name));
                        break;
                }
-               if (p) {
+               if (p && print_db_head) {
                        DLIST_PROMOTE(print_db_head, p);
                        p = print_db_head;
                }

Reply via email to