Fix a nasty bug : fulfill reply data must be copied, not just referenced

This commit is contained in:
Grégory Soutadé 2021-11-26 20:01:49 +01:00
parent 8413b844db
commit fd8ce841eb
2 changed files with 12 additions and 3 deletions

View File

@ -34,6 +34,12 @@ namespace gourou
class FulfillmentItem
{
public:
/**
* @brief Main constructor. Not to be called by user
*
* @param doc Fulfill reply
* @param user User pointer
*/
FulfillmentItem(pugi::xml_document& doc, User* user);
/**
@ -59,6 +65,7 @@ namespace gourou
std::string getResource();
private:
pugi::xml_document fulfillDoc;
pugi::xml_node metadatas;
pugi::xml_document rights;
std::string downloadURL;

View File

@ -24,9 +24,11 @@
namespace gourou
{
FulfillmentItem::FulfillmentItem(pugi::xml_document& doc, User* user)
: fulfillDoc()
{
metadatas = doc.select_node("//metadata").node();
fulfillDoc.reset(doc); /* We must keep a copy */
metadatas = fulfillDoc.select_node("//metadata").node();
if (!metadatas)
EXCEPTION(FFI_INVALID_FULFILLMENT_DATA, "No metadata tag in document");
@ -49,7 +51,7 @@ namespace gourou
buildRights(licenseToken, user);
}
void FulfillmentItem::buildRights(const pugi::xml_node& licenseToken, User* user)
{
pugi::xml_node decl = rights.append_child(pugi::node_declaration);