Bugfix/fix unittest for cla7aye15 i4nd fix skipspaces (#6590)

* Fix conditional check in SkipSpaces function to prevent out-of-bound access.

The `SkipSpaces` function's condition was updated to ensure that the pointer check `in != end` is evaluated before dereferencing the pointer. This change prevents potential out-of-bound access when the input pointer reaches the end.

* Avoid input is wrong

* Fix all in != end

* Fix some minor bugs

* Change size to capacity

* Obj: Fix unittest
This commit is contained in:
Kim Kulling
2026-03-24 21:23:38 +01:00
committed by GitHub
parent fcb1702162
commit 8ff005570a
4 changed files with 296 additions and 286 deletions

View File

@@ -106,8 +106,8 @@ protected:
void getFace(aiPrimitiveType type);
/// Reads the material description.
void getMaterialDesc();
/// Gets a comment.
void getComment();
/// Skip a comment.
void skipComment();
/// Gets a a material library.
void getMaterialLib();
/// Creates a new material.
@@ -115,9 +115,9 @@ protected:
/// Gets the group name from file.
void getGroupName();
/// Gets the group number from file.
void getGroupNumber();
void skipGroupNumber();
/// Gets the group number and resolution from file.
void getGroupNumberAndResolution();
void skipGroupNumberAndResolution();
/// Returns the index of the material. Is -1 if not material was found.
int getMaterialIndex(const std::string &strMaterialName);
/// Parse object name
@@ -135,23 +135,23 @@ private:
/// Default material name
static constexpr const char DEFAULT_MATERIAL[] = AI_DEFAULT_MATERIAL_NAME;
//! Iterator to current position in buffer
DataArrayIt m_DataIt;
DataArrayIt mDataIt{};
//! Iterator to end position of buffer
DataArrayIt m_DataItEnd;
DataArrayIt mDataItEnd{};
//! Pointer to model instance
std::unique_ptr<ObjFile::Model> m_pModel;
std::unique_ptr<ObjFile::Model> mModel{};
//! Current line (for debugging)
unsigned int m_uiLine;
unsigned int mLine{ 0 };
//! Helper buffer
char m_buffer[Buffersize];
char mBuffer[Buffersize];
/// End of buffer
const char *mEnd;
const char *mEnd{ nullptr };
/// Pointer to IO system instance.
IOSystem *m_pIO;
IOSystem *mIO{ nullptr };
//! Pointer to progress handler
ProgressHandler *m_progress;
ProgressHandler *mProgress{ nullptr };
/// Path to the current model, name of the obj file where the buffer comes from
const std::string m_originalObjFileName;
const std::string mOriginalObjFileName{};
};
} // Namespace Assimp