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

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

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

Modified:
   branches/SAMBA_3_0/source/printing/printing_db.c


Changeset:
Modified: branches/SAMBA_3_0/source/printing/printing_db.c
===================================================================
--- branches/SAMBA_3_0/source/printing/printing_db.c    2006-06-20 01:25:27 UTC 
(rev 16391)
+++ branches/SAMBA_3_0/source/printing/printing_db.c    2006-06-20 01:25:31 UTC 
(rev 16392)
@@ -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