From 1c8a871aaf11745b8de4c0601e514eebdfb09436 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 20 Jun 2006 01:25:31 +0000 Subject: r16392: Klockwork #1168. Protect against null deref. Jeremy. (This used to be commit cab256d72a91f59432e28e9623c10384d9ca2b5e) --- source3/printing/printing_db.c | 6 ++++-- 1 file 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; } -- cgit