svn commit: samba r5772 - in trunk/source/printing: .
vlendec at samba.org
vlendec at samba.org
Sat Mar 12 10:41:26 GMT 2005
Author: vlendec
Date: 2005-03-12 10:41:26 +0000 (Sat, 12 Mar 2005)
New Revision: 5772
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5772
Log:
Fix two memleaks
Modified:
trunk/source/printing/printerdb_file.c
Changeset:
Modified: trunk/source/printing/printerdb_file.c
===================================================================
--- trunk/source/printing/printerdb_file.c 2005-03-12 09:59:13 UTC (rev 5771)
+++ trunk/source/printing/printerdb_file.c 2005-03-12 10:41:26 UTC (rev 5772)
@@ -761,29 +761,24 @@
prs_struct ps;
WERROR result = WERR_OK;
- if (asprintf(&filename, "%s/%s/%s", file_root, SECDESC_PREFIX, printername) < 0)
+ filename = talloc_asprintf(mem_ctx, "%s/%s/%s", file_root,
+ SECDESC_PREFIX, printername);
+
+ if (filename == NULL)
return WERR_NOMEM;
- if (!read_complete_file(mem_ctx, filename, &buf, &len)) {
- result = WERR_INVALID_SECURITY_DESCRIPTOR;
- goto done;
- }
+ if (!read_complete_file(mem_ctx, filename, &buf, &len))
+ return WERR_INVALID_SECURITY_DESCRIPTOR;
- if (!prs_init(&ps, 0, mem_ctx, UNMARSHALL)) {
- result = WERR_NOMEM;
- goto done;
- }
+ if (!prs_init(&ps, 0, mem_ctx, UNMARSHALL))
+ return WERR_NOMEM;
prs_give_memory(&ps, buf, len, True);
- if (!sec_io_desc_buf("file_get_secdesc", secdesc_ctr, &ps, 1)) {
- result = WERR_NOMEM;
- goto done;
- }
+ result = sec_io_desc_buf("file_get_secdesc", secdesc_ctr, &ps, 1) ?
+ WERR_OK : WERR_NOMEM;
-done:
- if (&ps)
- prs_mem_free(&ps);
+ prs_mem_free(&ps);
return result;
}
@@ -793,7 +788,10 @@
char *filename;
WERROR result = WERR_OK;
- if (asprintf(&filename, "%s/%s/%s", file_root, SECDESC_PREFIX, printername) < 0)
+ filename = talloc_asprintf(mem_ctx, "%s/%s/%s", file_root,
+ SECDESC_PREFIX, printername);
+
+ if (filename == NULL)
return WERR_NOMEM;
prs_init(&ps, (uint32)sec_desc_size(secdesc_ctr->sec) +
@@ -811,9 +809,7 @@
}
done:
- if (&ps)
- prs_mem_free(&ps);
-
+ prs_mem_free(&ps);
return result;
}
More information about the samba-cvs
mailing list