Avoid using PL_na with newSVpv
[email protected] (Torsten Schoenfeld)
| Newsgroups | perl.xs |
|---|---|
| Message-ID | <[email protected]> |
I recently tracked down a difficult bug that occured only when one of my XS modules was used in conjunction with certain other XS modules (e.g., XML::Parser or String::Approx). It turned out to be due to the incorrect assumption that PL_na will always be zero. Specifically, we used newSVpv (string, PL_na) // do not do this when we didn't have the string's length. This breaks if some other XS module writes to PL_na (via SvPV, most likely). So always use an explicit zero instead: newSVpv (string, 0)