From 01acd4bb3833733f7487ad86ea6542239fe3c90b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Nov 2007 13:56:36 -0800 Subject: Remove pstring from printing/*.c except for the tdb_unpack requirement (I'll be making that an allocating interface later). Jeremy. (This used to be commit d2ee75326ac291ab4f1860075ba35f58703c7d9d) --- source3/printing/printing_db.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source3/printing/printing_db.c') diff --git a/source3/printing/printing_db.c b/source3/printing/printing_db.c index db736765fc..94319f96d0 100644 --- a/source3/printing/printing_db.c +++ b/source3/printing/printing_db.c @@ -33,7 +33,7 @@ struct tdb_print_db *get_print_db_byname(const char *printername) { struct tdb_print_db *p = NULL, *last_entry = NULL; int num_open = 0; - pstring printdb_path; + char *printdb_path = NULL; bool done_become_root = False; SMB_ASSERT(printername != NULL); @@ -78,7 +78,7 @@ struct tdb_print_db *get_print_db_byname(const char *printername) p = print_db_head; } } - + if (!p) { /* Create one. */ p = SMB_MALLOC_P(struct tdb_print_db); @@ -90,9 +90,13 @@ struct tdb_print_db *get_print_db_byname(const char *printername) DLIST_ADD(print_db_head, p); } - pstrcpy(printdb_path, lock_path("printing/")); - pstrcat(printdb_path, printername); - pstrcat(printdb_path, ".tdb"); + if (asprintf(&printdb_path, "%s%s.tdb", + lock_path("printing/"), + printername) < 0) { + DLIST_REMOVE(print_db_head, p); + SAFE_FREE(p); + return NULL; + } if (geteuid() != 0) { become_root(); @@ -109,9 +113,11 @@ struct tdb_print_db *get_print_db_byname(const char *printername) DEBUG(0,("get_print_db: Failed to open printer backend database %s.\n", printdb_path )); DLIST_REMOVE(print_db_head, p); + SAFE_FREE(printdb_path); SAFE_FREE(p); return NULL; } + SAFE_FREE(printdb_path); fstrcpy(p->printer_name, printername); p->ref_count++; return p; -- cgit