diff options
author | Roland McGrath <roland@gnu.org> | 2001-09-29 04:28:55 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-09-29 04:28:55 +0000 |
commit | 4226fd1b67d1f1571ca21128eaf4a7112bc1ea06 (patch) | |
tree | 9165a45db26f127aa00f59b393845c6f7aff8ab0 /libstore | |
parent | 35735005043deeb892db76161abbbefaf02e6b34 (diff) |
2001-09-28 Roland McGrath <roland@frob.com>
* decode.c (store_std_leaf_decode): Actually copy data into MISC.
Don't call malloc for it when MISC_LEN is zero, just store null.
Diffstat (limited to 'libstore')
-rw-r--r-- | libstore/decode.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/libstore/decode.c b/libstore/decode.c index 33e99492..cc063d34 100644 --- a/libstore/decode.c +++ b/libstore/decode.c @@ -1,7 +1,7 @@ /* Store wire decoding - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. - Written by Miles Bader <miles@gnu.ai.mit.edu> + Copyright (C) 1996,97,98,2001 Free Software Foundation, Inc. + Written by Miles Bader <miles@gnu.org> This file is part of the GNU Hurd. The GNU Hurd is free software; you can redistribute it and/or @@ -64,21 +64,28 @@ store_std_leaf_decode (struct store_enc *enc, if (name_len > 0 && enc->data[enc->cur_data + name_len - 1] != '\0') return EINVAL; /* Name not terminated. */ - misc = malloc (misc_len); - if (! misc) - return ENOMEM; - if (name_len > 0) { name = strdup (enc->data + enc->cur_data); if (! name) + return ENOMEM; + } + else + name = 0; + + if (misc_len > 0) + { + misc = malloc (misc_len); + if (! misc) { - free (misc); + if (name) + free (name); return ENOMEM; } + memcpy (misc, enc->data + enc->cur_data + name_len, misc_len); } else - name = 0; + misc = 0; /* Read encoded ports (be careful to deallocate this if we barf). */ port = enc->ports[enc->cur_port++]; @@ -87,7 +94,8 @@ store_std_leaf_decode (struct store_enc *enc, if (err) { mach_port_deallocate (mach_task_self (), port); - free (misc); + if (misc) + free (misc); if (name) free (name); } |