diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index e23488a3d..8ed0628d6 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -16,6 +16,11 @@ should also be read to understand what has changed since earlier releases. +### Perl CA support for empty long strings + +The Perl CA bindings have been fixed to handle zero-length long string data +properly. + ### `aao` gains `OMSL` and `DOL` The `aao` record types gains the same `DOL` functionality found diff --git a/modules/ca/src/perl/Cap5.xs b/modules/ca/src/perl/Cap5.xs index e17fcbaf0..5da894808 100644 --- a/modules/ca/src/perl/Cap5.xs +++ b/modules/ca/src/perl/Cap5.xs @@ -208,6 +208,8 @@ SV * newSVdbr(struct event_handler_args *peha) { if (is_primitive) { if (value_type == DBR_CHAR) { /* Long string => Perl scalar */ + if (peha->count == 0) + return newSVpvn(peha->dbr, 0); ((char *)peha->dbr) [peha->count - 1] = 0; return newSVpv(peha->dbr, 0); } @@ -278,8 +280,12 @@ SV * newSVdbr(struct event_handler_args *peha) { char *str = dbr_value_ptr(peha->dbr, peha->type); /* Long string => Perl scalar */ - str[peha->count - 1] = 0; - val = newSVpv(str, 0); + if (peha->count == 0) + val = newSVpvn(str, 0); + else { + str[peha->count - 1] = 0; + val = newSVpv(str, 0); + } } else if (peha->count == 1) { /* Single value => Perl scalar */ val = newSVdbf(value_type,