Fix memory corruption in the aiGetExportFormatDescription() API. Clarify Exporter doc.
parent
75fd29ac19
commit
be5fc42e16
|
@ -61,6 +61,8 @@ ASSIMP_API size_t aiGetExportFormatCount(void)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex)
|
ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex)
|
||||||
{
|
{
|
||||||
|
// Note: this is valid as the index always pertains to a builtin exporter,
|
||||||
|
// for which the returned structure is guaranteed to be of static storage duration.
|
||||||
return Exporter().GetExportFormatDescription(pIndex);
|
return Exporter().GetExportFormatDescription(pIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -437,6 +437,11 @@ const aiExportFormatDesc* Exporter :: GetExportFormatDescription( size_t pIndex
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return from static storage if the requested index is built-in.
|
||||||
|
if (pIndex < sizeof(gExporters) / sizeof(gExporters[0])) {
|
||||||
|
return &gExporters[pIndex].mDescription;
|
||||||
|
}
|
||||||
|
|
||||||
return &pimpl->mExporters[pIndex].mDescription;
|
return &pimpl->mExporters[pIndex].mDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,11 @@ public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Returns the number of export file formats available in the current
|
/** Returns the number of export file formats available in the current
|
||||||
* Assimp build. Use #Exporter::GetExportFormatDescription to
|
* Assimp build. Use #Exporter::GetExportFormatDescription to
|
||||||
* retrieve infos of a specific export format */
|
* retrieve infos of a specific export format.
|
||||||
|
*
|
||||||
|
* This includes built-in exporters as well as exporters registered
|
||||||
|
* using #RegisterExporter.
|
||||||
|
**/
|
||||||
size_t GetExportFormatCount() const;
|
size_t GetExportFormatCount() const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,6 +263,12 @@ public:
|
||||||
/** Returns a description of the nth export file format. Use #
|
/** Returns a description of the nth export file format. Use #
|
||||||
* #Exporter::GetExportFormatCount to learn how many export
|
* #Exporter::GetExportFormatCount to learn how many export
|
||||||
* formats are supported.
|
* formats are supported.
|
||||||
|
*
|
||||||
|
* The returned pointer is of static storage duration iff the
|
||||||
|
* pIndex pertains to a built-in exporter (i.e. one not registered
|
||||||
|
* via #RegistrerExporter). It is restricted to the life-time of the
|
||||||
|
* #Exporter instance otherwise.
|
||||||
|
*
|
||||||
* @param pIndex Index of the export format to retrieve information
|
* @param pIndex Index of the export format to retrieve information
|
||||||
* for. Valid range is 0 to #Exporter::GetExportFormatCount
|
* for. Valid range is 0 to #Exporter::GetExportFormatCount
|
||||||
* @return A description of that specific export format.
|
* @return A description of that specific export format.
|
||||||
|
@ -269,7 +279,9 @@ public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Register a custom exporter. Custom export formats are limited to
|
/** Register a custom exporter. Custom export formats are limited to
|
||||||
* to the current #Exporter instance and do not affect the
|
* to the current #Exporter instance and do not affect the
|
||||||
* library globally.
|
* library globally. The indexes under which the format's
|
||||||
|
* export format description can be queried are assigned
|
||||||
|
* monotonously.
|
||||||
* @param desc Exporter description.
|
* @param desc Exporter description.
|
||||||
* @return aiReturn_SUCCESS if the export format was successfully
|
* @return aiReturn_SUCCESS if the export format was successfully
|
||||||
* registered. A common cause that would prevent an exporter
|
* registered. A common cause that would prevent an exporter
|
||||||
|
|
Loading…
Reference in New Issue