Merge pull request #3999 from assimp/kimkulling-issue_3974
Fix fuzzer issue in m3d-importerkimkulling-issue_3790
commit
209c66dff1
|
@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#ifndef AI_M3DWRAPPER_H_INC
|
#ifndef AI_M3DWRAPPER_H_INC
|
||||||
#define AI_M3DWRAPPER_H_INC
|
#define AI_M3DWRAPPER_H_INC
|
||||||
|
|
||||||
#if !(ASSIMP_BUILD_NO_EXPORT || ASSIMP_BUILD_NO_M3D_EXPORTER) || !ASSIMP_BUILD_NO_M3D_IMPORTER
|
#if !(ASSIMP_BUILD_NO_EXPORT || ASSIMP_BUILD_NO_M3D_EXPORTER) || !ASSIMP_BUILD_NO_M3D_IMPORTER
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -62,41 +63,68 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "m3d.h"
|
#include "m3d.h"
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
class IOSystem;
|
class IOSystem;
|
||||||
|
|
||||||
|
/// brief The M3D-Wrapper, provudes c++ access to the data.
|
||||||
class M3DWrapper {
|
class M3DWrapper {
|
||||||
m3d_t *m3d_ = nullptr;
|
|
||||||
unsigned char *saved_output_ = nullptr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Construct an empty M3D model
|
/// Construct an empty M3D model
|
||||||
explicit M3DWrapper();
|
explicit M3DWrapper();
|
||||||
|
|
||||||
// Construct an M3D model from provided buffer
|
/// Construct an M3D model from provided buffer
|
||||||
// NOTE: The m3d.h SDK function does not mark the data as const. Have assumed it does not write.
|
/// @note The m3d.h SDK function does not mark the data as const. Have assumed it does not write.
|
||||||
// BUG: SECURITY: The m3d.h SDK cannot be informed of the buffer size. BUFFER OVERFLOW IS CERTAIN
|
/// BUG: SECURITY: The m3d.h SDK cannot be informed of the buffer size. BUFFER OVERFLOW IS CERTAIN
|
||||||
explicit M3DWrapper(IOSystem *pIOHandler, const std::vector<unsigned char> &buffer);
|
explicit M3DWrapper(IOSystem *pIOHandler, const std::vector<unsigned char> &buffer);
|
||||||
|
|
||||||
~M3DWrapper();
|
/// Theclasss destructor.
|
||||||
|
~M3DWrapper();
|
||||||
|
|
||||||
void reset();
|
/// Will reset the wrapper, all data will become nullptr.
|
||||||
|
void reset();
|
||||||
|
|
||||||
// Name
|
// The Name access, empty string returned when no m3d instance.
|
||||||
inline std::string Name() const {
|
std::string Name() const;
|
||||||
if (m3d_) return std::string(m3d_->name);
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute a save
|
/// Executes a save.
|
||||||
unsigned char *Save(int quality, int flags, unsigned int &size);
|
unsigned char *Save(int quality, int flags, unsigned int &size);
|
||||||
|
|
||||||
|
/// Clearer
|
||||||
void ClearSave();
|
void ClearSave();
|
||||||
|
|
||||||
inline explicit operator bool() const { return m3d_ != nullptr; }
|
/// True for m3d instance exists.
|
||||||
|
explicit operator bool() const;
|
||||||
|
|
||||||
// Allow direct access to M3D API
|
// Allow direct access to M3D API
|
||||||
inline m3d_t *operator->() const { return m3d_; }
|
m3d_t *operator->() const;
|
||||||
inline m3d_t *M3D() const { return m3d_; }
|
m3d_t *M3D() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
m3d_t *m3d_ = nullptr;
|
||||||
|
unsigned char *saved_output_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline std::string M3DWrapper::Name() const {
|
||||||
|
if (nullptr != m3d_) {
|
||||||
|
if (nullptr != m3d_->name) {
|
||||||
|
return std::string(m3d_->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline M3DWrapper::operator bool() const {
|
||||||
|
return m3d_ != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline m3d_t *M3DWrapper::operator->() const {
|
||||||
|
return m3d_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline m3d_t *M3DWrapper::M3D() const {
|
||||||
|
return m3d_;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Assimp
|
} // namespace Assimp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue