]> git.vpit.fr Git - perl/modules/Sub-Op.git/commitdiff
When cloning a config, eallocate one char more for the name
authorVincent Pit <vince@profvince.com>
Tue, 20 Apr 2010 21:13:23 +0000 (23:13 +0200)
committerVincent Pit <vince@profvince.com>
Tue, 20 Apr 2010 21:13:23 +0000 (23:13 +0200)
Op.xs

diff --git a/Op.xs b/Op.xs
index 6a71219845dace3c81e3860b18970d4fddd3e3fe..d6dc30c3a9ebda75a9d9218b904bc1c2e58c89ec 100644 (file)
--- a/Op.xs
+++ b/Op.xs
@@ -150,9 +150,10 @@ sub_op_config_t *sub_op_dup(pTHX_ const sub_op_config_t *orig) {
  sub_op_config_t *dupe = PerlMemShared_malloc(sizeof *dupe);
 
  len           = orig->namelen;
- if (len && orig->name) {
-  dupe->name   = PerlMemShared_malloc(len);
+ if (orig->name) {
+  dupe->name   = PerlMemShared_malloc(len + 1);
   Copy(orig->name, dupe->name, len, char);
+  ((char *) dupe->name)[len] = '\0';
  } else {
   dupe->name   = NULL;
  }