From 578b3317af12be7c5ecedd8240c09a3d513fa382 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 19 Jun 2014 07:43:56 +0200 Subject: python/tag.cc: ensure that the final \n is there when duplicating section data --- python/tag.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/tag.cc b/python/tag.cc index 50786cee..8f483467 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -338,11 +338,14 @@ static PyObject *TagFileNext(PyObject *Self) const char *Start; const char *Stop; Obj.Section->Object.GetSection(Start,Stop); - // Duplicate the data - Obj.Section->Data = new char[Stop-Start]; - strncpy(Obj.Section->Data, Start, Stop-Start); + // Duplicate the data and + // append a \n because GetSection() will only give us a single \n + // but Scan() needs \n\n to work + Obj.Section->Data = new char[Stop-Start+2]; + snprintf(Obj.Section->Data, Stop-Start+2, "%s\n", Start); // Rescan it - Obj.Section->Object.Scan(Obj.Section->Data, Stop-Start); + if(Obj.Section->Object.Scan(Obj.Section->Data, Stop-Start) == false) + return HandleErrors(NULL); Py_INCREF(Obj.Section); return HandleErrors(Obj.Section); -- cgit v1.2.3