summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-07-25 21:23:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:21 -0500
commit9d4fa2b27b746d6a5716bfa049b2a1ee191ba6d5 (patch)
tree95b2d625739ad9ad0eb4c395dd1f3eda9b9db3d0 /source3
parent1a0b57b5f523bdf787a8024303b661ea9004215f (diff)
downloadsamba-9d4fa2b27b746d6a5716bfa049b2a1ee191ba6d5.tar.gz
samba-9d4fa2b27b746d6a5716bfa049b2a1ee191ba6d5.tar.bz2
samba-9d4fa2b27b746d6a5716bfa049b2a1ee191ba6d5.zip
r17244: There were several error paths where NT_PRINTER_INFO_LEVEL
wasn't being freed - also one enum jobs case where the NT_PRINTER_INFO_LEVEL and queue weren't being freed. Strange that Coverity or Klokwork didn't pick these up. Hopefully will fix #3962. Jeremy. (This used to be commit bb264123872bfec42ad85ec0c8afa3a8c7d1811e)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 3dbad208cc..db098e74be 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -441,7 +441,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename)
const char *servername;
fstring sname;
BOOL found=False;
- NT_PRINTER_INFO_LEVEL *printer;
+ NT_PRINTER_INFO_LEVEL *printer = NULL;
WERROR result;
DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename)));
@@ -532,6 +532,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename)
printername++;
if ( strequal(printername, aprinter) ) {
+ free_a_printer( &printer, 2);
found = True;
break;
}
@@ -541,6 +542,8 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename)
free_a_printer( &printer, 2);
}
+ free_a_printer( &printer, 2);
+
if ( !found ) {
DEBUGADD(4,("Printer not found\n"));
return False;
@@ -3551,6 +3554,7 @@ static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY
if((info->data=SMB_REALLOC_ARRAY(info->data, SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) {
DEBUG(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n"));
+ free_a_printer(&printer, 2);
return False;
}
@@ -4181,6 +4185,7 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **
*pp_printer = NULL;
if ((printer = SMB_MALLOC_P(PRINTER_INFO_3)) == NULL) {
DEBUG(2,("construct_printer_info_3: malloc fail.\n"));
+ free_a_printer(&ntprinter, 2);
return False;
}
@@ -4983,8 +4988,10 @@ static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst
if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
return WERR_INVALID_PRINTER_NAME;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version)))
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) {
+ free_a_printer(&printer, 2);
return WERR_UNKNOWN_PRINTER_DRIVER;
+ }
fill_printer_driver_info_1(info, driver, servername, architecture);
@@ -5043,8 +5050,10 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst
if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
return WERR_INVALID_PRINTER_NAME;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version)))
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) {
+ free_a_printer(&printer, 2);
return WERR_UNKNOWN_PRINTER_DRIVER;
+ }
fill_printer_driver_info_2(info, driver, servername);
@@ -6611,22 +6620,24 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO
if (*returned == 0) {
SAFE_FREE(queue);
+ free_a_printer(&ntprinter, 2);
return WERR_OK;
}
switch (level) {
case 1:
wret = enumjobs_level1(queue, snum, ntprinter, buffer, offered, needed, returned);
- return wret;
+ break;
case 2:
wret = enumjobs_level2(queue, snum, ntprinter, buffer, offered, needed, returned);
- return wret;
+ break;
default:
- SAFE_FREE(queue);
*returned=0;
wret = WERR_UNKNOWN_LEVEL;
+ break;
}
+ SAFE_FREE(queue);
free_a_printer( &ntprinter, 2 );
return wret;
}