}
sub_op_config_t *sub_op_dup(pTHX_ const sub_op_config_t *orig) {
+ STRLEN len;
sub_op_config_t *dupe = PerlMemShared_malloc(sizeof *dupe);
- dupe->namelen = orig->namelen;
- dupe->name = PerlMemShared_malloc(dupe->namelen);
- Copy(orig->name, dupe->name, dupe->namelen, char);
+ len = orig->namelen;
+ if (len && orig->name) {
+ dupe->name = PerlMemShared_malloc(len);
+ Copy(orig->name, dupe->name, len, char);
+ } else {
+ dupe->name = NULL;
+ }
+ dupe->namelen = len;
+
- dupe->pp = orig->pp;
- dupe->check = orig->check;
- dupe->ud = orig->ud;
+ dupe->pp = orig->pp;
+ dupe->check = orig->check;
+ dupe->ud = orig->ud;
return dupe;
}