summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-20 01:25:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:18:51 -0500
commit1c8a871aaf11745b8de4c0601e514eebdfb09436 (patch)
tree516bee0b7a0badfa5b0dbc90dac2e7474bbca5ed
parente98a2e1fca5f1cb61e1441520a695073bab1bec4 (diff)
downloadsamba-1c8a871aaf11745b8de4c0601e514eebdfb09436.tar.gz
samba-1c8a871aaf11745b8de4c0601e514eebdfb09436.tar.bz2
samba-1c8a871aaf11745b8de4c0601e514eebdfb09436.zip
r16392: Klockwork #1168. Protect against null deref.
Jeremy. (This used to be commit cab256d72a91f59432e28e9623c10384d9ca2b5e)
-rw-r--r--source3/printing/printing_db.c6
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;
}