Skip to content

Commit e3c4b94

Browse files
committed
Fix crash with carriage returns
1 parent e589823 commit e3c4b94

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

model/off/off_document_4d.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,18 @@ Ref<OFFDocument4D> OFFDocument4D::_import_load_from_raw_text(const String &p_raw
466466
int current_vertex_index = 0;
467467
int min_items_per_line = 3;
468468
bool can_warn = true;
469+
if (p_raw_text.contains("\r")) {
470+
WARN_PRINT("OFF import: Warning: OFF file " + p_path + " contains carriage return characters (\\r). Remove them to silence this warning.");
471+
can_warn = false;
472+
}
469473
const PackedStringArray lines = p_raw_text.split("\n", false);
470474
for (const String &line : lines) {
471475
if (line.is_empty() || line.begins_with("#")) {
472476
continue;
473477
}
474478
if (line.contains("OFF")) {
475479
// "OFF" by itself is 3D OFF.
476-
if (line != "OFF") {
480+
if (line != "OFF" && is_digit(line[0])) {
477481
const int declared_dimension = line.to_int();
478482
if (declared_dimension < 3) {
479483
min_items_per_line = declared_dimension;

0 commit comments

Comments
 (0)