diff options
-rw-r--r-- | source3/printing/printing_db.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source3/printing/printing_db.c b/source3/printing/printing_db.c index adea10dfa6..c62409c890 100644 --- a/source3/printing/printing_db.c +++ b/source3/printing/printing_db.c @@ -55,7 +55,9 @@ struct tdb_print_db *get_print_db_byname(const char *printername) /* 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 @@ struct tdb_print_db *get_print_db_byname(const char *printername) 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; } |