mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
Bam reader robustness; allow threaded bam reading from Python
This commit is contained in:
parent
a55d915aea
commit
ea368dd559
@ -4465,6 +4465,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
|
||||
set_fancy_bit(FB_effects, !_effects->is_empty());
|
||||
set_fancy_bit(FB_tag, !_tag_data.empty());
|
||||
|
||||
// Mark the bounds stale.
|
||||
++_next_update;
|
||||
|
||||
return pi;
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,12 @@ init() {
|
||||
_file_stdfloat_double = scan.get_bool();
|
||||
}
|
||||
|
||||
if (scan.get_current_index() > header.get_length()) {
|
||||
bam_cat.error()
|
||||
<< "Bam header is too short.\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1230,6 +1236,12 @@ p_read_object() {
|
||||
|
||||
int object_id = read_object_id(scan);
|
||||
|
||||
if (scan.get_current_index() > dg.get_length()) {
|
||||
bam_cat.error()
|
||||
<< "Found truncated datagram in bam stream\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// There are two cases (not counting the special _remove_flag case,
|
||||
// above). Either this is a new object definition, or this is a
|
||||
// reference to an object that was previously defined.
|
||||
@ -1271,6 +1283,12 @@ p_read_object() {
|
||||
created_obj._ptr->fillin(scan, this);
|
||||
_now_creating = was_creating;
|
||||
|
||||
if (scan.get_remaining_size() > 0) {
|
||||
bam_cat.warning()
|
||||
<< "Skipping " << scan.get_remaining_size() << " remaining bytes "
|
||||
<< "in datagram containing type " << type << "\n";
|
||||
}
|
||||
|
||||
} else {
|
||||
// We are receiving a new object. Now we can call the factory
|
||||
// to create the object.
|
||||
@ -1371,6 +1389,13 @@ p_read_object() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sanity check that we read the expected number of bytes.
|
||||
if (scan.get_current_index() > dg.get_length()) {
|
||||
bam_cat.error()
|
||||
<< "End of datagram reached while reading bam object "
|
||||
<< type << ": " << (void *)created_obj._ptr << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return object_id;
|
||||
|
@ -143,9 +143,9 @@ PUBLISHED:
|
||||
|
||||
INLINE const LoaderOptions &get_loader_options() const;
|
||||
INLINE void set_loader_options(const LoaderOptions &options);
|
||||
|
||||
TypedWritable *read_object();
|
||||
bool read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr);
|
||||
|
||||
BLOCKING TypedWritable *read_object();
|
||||
BLOCKING bool read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr);
|
||||
|
||||
INLINE bool is_eof() const;
|
||||
bool resolve();
|
||||
|
Loading…
x
Reference in New Issue
Block a user