[MINC-development] bug in upet2mnc
jcupitt at gmail.com
jcupitt at gmail.com
Fri Jul 23 07:25:50 EDT 2010
Hi, I think I've found a bug in upet2mnc.
If i run the version that comes with Ubuntu Lucid (2.0.18) on an x64
machine, I get:
$ upet2mnc c4.img poop.mnc
Starting conversion
- Input header: c4.img.hdr
- Input image: c4.img
- Output file: poop.mnc
WARNING: Unrecognized keyword manufacturer
Segmentation fault
$
Looking at the source, the problem is in the message() function. It
includes this code:
va_start(ap, fmt);
if (_verbose_flag || level != MSG_INFO) {
if (level != MSG_INFO) {
if (prefix_str != NULL) {
fprintf(stderr, "%s", prefix_str);
}
vfprintf(stderr, fmt, ap);
}
if (prefix_str != NULL) {
fprintf(stdout, "%s", prefix_str);
}
vfprintf(stdout, fmt, ap);
}
va_end(ap);
So it's setting up ap once but then, for non-info messages, using it
twice. One simple fix would be to put the va_start() around each
vfprintf():
if (_verbose_flag || level != MSG_INFO) {
if (level != MSG_INFO) {
if (prefix_str != NULL) {
fprintf(stderr, "%s", prefix_str);
}
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
if (prefix_str != NULL) {
fprintf(stdout, "%s", prefix_str);
}
va_start(ap, fmt);
vfprintf(stdout, fmt, ap);
va_end(ap);
}
Which fixes the segv, phew.
John
More information about the MINC-development
mailing list