Setting an XMP seq to the empty list segfaults

Bug #510393 reported by Olivier Tilloy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Released
Medium
Olivier Tilloy

Bug Description

This happens with pyexiv2 0.2 (development branch) compiled against libexiv2 0.19.

After setting the value of an XMP tag of type 'seq ProperName' to the empty list [], writing back the metadata raises a segmentation fault. Test script to reproduce:

import pyexiv2
m = pyexiv2.ImageMetadata('image.jpg')
m.read()
m['Xmp.dc.creator'] = pyexiv2.XmpTag('Xmp.dc.creator', [])
m.write()

I am not sure whether emptying a seq is valid anyway, this needs to be investigated.

Tags: xmp

Related branches

Revision history for this message
Olivier Tilloy (osomon) wrote :

The following minimal C++ program reproduces the issue:

#include "exiv2/image.hpp"
int main(int argc, char** argv)
{
    Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
    image->readMetadata();
    image->xmpData()["Xmp.dc.creator"].setValue(0);
    image->writeMetadata();
    return 0;
}

(to be compiled with `g++ -lexiv2`)
When run with the path to an image file as parameter, here is the output:

terminate called after throwing an instance of 'Exiv2::BasicError<char>'
  what(): Value not set

libexiv2 doesn't accept empty values, which makes sense. To prevent this from happening, pyexiv2 could raise an exception when setting an array (seq, bag, alt) value to the empty list.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Note that the same applies to setting the value of a tag of type LangAlt to the empty dictionary. This should be prevented by raising an exception.

Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Confirmed → Fix Released
status: Fix Released → Fix Committed
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.