r24410: - I got tricked by function naming. Contrary to what seemed obvious to me,
authorDerrell Lipman <derrell@samba.org>
Tue, 14 Aug 2007 14:27:42 +0000 (14:27 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:29:41 +0000 (12:29 -0500)
  prs_mem_free() is not the function to be called to free memory allocated by
  prs_alloc_mem().  I've added a comment so others may not get bitten too.

- Remove incorrect memory free calls added yesterday to replace SAFE_FREE.
  The memory is actually now on a talloc context, so gets freed by the caller
  when that context is freed.  We don't need to free it iternally.

Derrell

source/libsmb/libsmbclient.c
source/rpc_parse/parse_prs.c

index af619e8f3a0b880b414df25cdfe8053942da2de1..bcbdd5a15adb390b8e7bf1d18a264d88e2b9f26f 100644 (file)
@@ -5142,8 +5142,6 @@ cacl_set(TALLOC_CTX *ctx,
        switch (mode) {
        case SMBC_XATTR_MODE_REMOVE_ALL:
                 old->dacl->num_aces = 0;
-                prs_mem_free(old->dacl->aces);
-                prs_mem_free(&old->dacl);
                 old->dacl = NULL;
                 dacl = old->dacl;
                 break;
@@ -5162,8 +5160,6 @@ cacl_set(TALLOC_CTX *ctx,
                                        }
                                        old->dacl->num_aces--;
                                        if (old->dacl->num_aces == 0) {
-                                                prs_mem_free(&old->dacl->aces);
-                                                prs_mem_free(&old->dacl);
                                                old->dacl = NULL;
                                        }
                                        found = True;
index 26bd3a5cec95c6ed53a5c6f667ca74f4e881b70d..c51e1dff4a0b74e7e3383bc16e8a7d97275adc85 100644 (file)
@@ -122,6 +122,10 @@ BOOL prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, BOOL io)
 
 /*******************************************************************
  Delete the memory in a parse structure - if we own it.
+
+ NOTE: Contrary to the somewhat confusing naming, this function is not
+       intended for freeing memory allocated by prs_alloc_mem().  That memory
+       is attached to the talloc context given by ps->mem_ctx.
  ********************************************************************/
 
 void prs_mem_free(prs_struct *ps)