perl - PerlXS:尝试释放可能会崩溃()
问题描述
我看到了细微的崩溃,我认为这取决于以下 XS 代码:
void
tiff_ReadRawStrip (tif, strip, size)
TIFF *tif
uint32_t strip
tmsize_t size
INIT:
void *buf;
tmsize_t stripsize, bufsize;
PPCODE:
stripsize = TIFFStripSize(tif);
buf = (unsigned char *)_TIFFmalloc(stripsize);
bufsize = TIFFReadRawStrip(tif, strip, buf, size);
if (bufsize > 0) {
XPUSHs(sv_2mortal(newSVpvn(buf, bufsize)));
}
_TIFFfree(buf);
我想释放buf
两次吗?还有其他事情吗?
背景资料
几年前,我为 libtiff 编写了 Graphics::TIFF - Perl 绑定,并已在其他各种基于 Linux 的项目中成功使用它们。最近,我在 Github 操作中让它们在 Windows 上编译。
现在一个使用 Graphics::TIFF 的项目在单元测试期间在 Windows 上看到随机崩溃,这似乎是由 Graphics::TIFF 引起的。我只能在 Github 操作中重现它们,因为我无法访问 Windows 机器。
Linux 运行程序顺利通过,因此 Windows 编译器可能对某些事情不太宽容。
解决方案
推荐阅读
- swiftui - 如何通过自定义 ListStyle 删除列表中的单独行?
- java - 如何将我的 R 图形/文件集成到 Java 的 Swing 中?
- vb.net - Pkcs#11 异常:未找到带有序列号和标签的令牌
- javascript - React (HTML) 视频标签不会在移动设备上自动播放
- php - 将 PHP 变量添加到 HTML href
- java - 自动化的 Electron 桌面应用程序在 Electron 版本 4.0 中不工作,而在版本 2.0 上工作
- three.js - 三.js/WebGL 使透视相机缩小直到所有物体都可见
- python - 在 python 中运行循环代码的系统时间时出现 KeyError:859
- excel - 使用公式操作外部工作簿的最后一张表
- angular - App.modules.ts 中注册的模块在其他模块中不可用