summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-François Micouleau <jfm@samba.org>1999-09-25 14:18:48 +0000
committerJean-François Micouleau <jfm@samba.org>1999-09-25 14:18:48 +0000
commit0490365b04564750d73eea36af0ba1444d1d3d77 (patch)
tree67e7e5ca707f6cfdd82657479e9176be363878d9
parent7b88001235e6228ed672541f4afd2b06b610b8e1 (diff)
downloadsamba-0490365b04564750d73eea36af0ba1444d1d3d77.tar.gz
samba-0490365b04564750d73eea36af0ba1444d1d3d77.tar.bz2
samba-0490365b04564750d73eea36af0ba1444d1d3d77.zip
Don't duplicate forms anymore, just update the definition.
Many memory leaks fixed. J.F. (This used to be commit f328ae8024584599324ae4263bb9fb89a358279f)
-rw-r--r--source3/printing/nt_printing.c65
-rwxr-xr-xsource3/rpc_server/srv_spoolss.c39
2 files changed, 87 insertions, 17 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 9d357204df..a384b8e31a 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -128,22 +128,41 @@ add a form struct at the end of the list
****************************************************************************/
void add_a_form(nt_forms_struct **list, FORM form, int count)
{
- int n=count;
+ int n=0;
+ BOOL update;
+ fstring form_name;
- *list=Realloc(*list, (n+1)*sizeof(nt_forms_struct));
+ /*
+ * NT tries to add forms even when
+ * they are already in the base
+ * only update the values if already present
+ */
- (*list)[n].flag=form.flags;
- (*list)[n].width=form.size_x;
- (*list)[n].length=form.size_y;
- (*list)[n].left=form.left;
- (*list)[n].top=form.top;
- (*list)[n].right=form.right;
- (*list)[n].bottom=form.bottom;
+ update=False;
+
+ unistr2_to_ascii(form_name, &(form.name), sizeof(form_name)-1);
+ for (n=0; n<count && update==False; n++)
+ {
+ if (!strncmp((*list)[n].name, form_name, strlen(form_name)))
+ {
+ DEBUG(3, ("NT workaround, [%s] already exists\n", form_name));
+ update=True;
+ }
+ }
- if (form.name_ptr)
- {
- unistr2_to_ascii((*list)[n].name, &(form.name), sizeof((*list)[n].name)-1);
- }
+ if (update==False)
+ {
+ *list=Realloc(*list, (n+1)*sizeof(nt_forms_struct));
+ unistr2_to_ascii((*list)[n].name, &(form.name), sizeof((*list)[n].name)-1);
+ }
+
+ (*list)[n].flag=form.flags;
+ (*list)[n].width=form.size_x;
+ (*list)[n].length=form.size_y;
+ (*list)[n].left=form.left;
+ (*list)[n].top=form.top;
+ (*list)[n].right=form.right;
+ (*list)[n].bottom=form.bottom;
}
@@ -1123,6 +1142,7 @@ uint32 free_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
next_param=param->next;
DEBUG(6,("deleting param [%s]\n", param->value));
+ free(param->data);
free(param);
param=next_param;
}
@@ -1196,6 +1216,8 @@ uint32 get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level,
uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level)
{
uint32 success;
+ NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3;
+ char **dependentfiles;
switch (level)
{
@@ -1203,7 +1225,22 @@ uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level)
{
if (driver.info_3 != NULL)
{
- free(driver.info_3);
+ info3=driver.info_3;
+ dependentfiles=info3->dependentfiles;
+
+ while ( **dependentfiles != '\0' )
+ {
+ free (*dependentfiles);
+ dependentfiles++;
+ }
+
+ /* the last one (1 char !) */
+ free (*dependentfiles);
+
+ dependentfiles=info3->dependentfiles;
+ free (dependentfiles);
+
+ free(info3);
success=0;
}
else
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index eee3fcbe68..736ed07dca 100755
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -1728,7 +1728,7 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number,
{
DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum));
*printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_2 *));
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1 pointers at [%p]\n", *number+1, *printers));
+ DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2 pointers at [%p]\n", *number+1, *printers));
if (enum_printer_info_2( &((*printers)[*number]), snum, *number, conn) )
{
(*number)++;
@@ -2071,7 +2071,6 @@ static void make_unistr_array(UNISTR ***uni_array, char **char_array, char *wher
DEBUGADD(7,("last one\n"));
*uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1));
- (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR));
(*uni_array)[i]=0x0000;
DEBUGADD(6,("last one:done\n"));
}
@@ -2190,8 +2189,20 @@ static void spoolss_reply_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_
if (info1!=NULL) free(info1);
if (info2!=NULL) free(info2);
- if (info3!=NULL) free(info3);
+ if (info3!=NULL)
+ {
+ UNISTR **dependentfiles;
+ int j=0;
+ dependentfiles=info3->dependentfiles;
+ while ( dependentfiles[j] != NULL )
+ {
+ free(dependentfiles[j]);
+ j++;
+ }
+ free(dependentfiles);
+ free(info3);
+ }
}
/********************************************************************
@@ -3055,6 +3066,20 @@ static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, pr
}
case 3:
{
+ UNISTR **dependentfiles;
+
+ for (i=0; i<count; i++)
+ {
+ int j=0;
+ dependentfiles=(driver_info_3[i]).dependentfiles;
+ while ( dependentfiles[j] != NULL )
+ {
+ free(dependentfiles[j]);
+ j++;
+ }
+
+ free(dependentfiles);
+ }
free(driver_info_3);
break;
}
@@ -3617,6 +3642,8 @@ static void spoolss_reply_enumprintprocessors(SPOOL_Q_ENUMPRINTPROCESSORS *q_u,
r_u.info_1=info_1;
spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0);
+
+ free(info_1);
}
/****************************************************************************
@@ -3629,6 +3656,8 @@ static void api_spoolss_enumprintprocessors(pipes_struct *p, prs_struct *data,
spoolss_io_q_enumprintprocessors("", &q_u, data, 0);
spoolss_reply_enumprintprocessors(&q_u, rdata);
+
+ spoolss_io_free_buffer(&(q_u.buffer));
}
/****************************************************************************
@@ -3660,6 +3689,8 @@ static void spoolss_reply_enumprintmonitors(SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_
r_u.info_1=info_1;
spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0);
+
+ free(info_1);
}
/****************************************************************************
@@ -3672,6 +3703,8 @@ static void api_spoolss_enumprintmonitors(pipes_struct *p, prs_struct *data,
spoolss_io_q_enumprintmonitors("", &q_u, data, 0);
spoolss_reply_enumprintmonitors(&q_u, rdata);
+
+ spoolss_io_free_buffer(&(q_u.buffer));
}
/****************************************************************************