Repository: godot
Issue: Crash in StreamTexture::_load_data when dragging scene from content browser to scene
Labels: bug,topic:editor,needs testing,crash

### Godot version

3.5 custom, 32bit editor

### System information

Windows 10, GLES3, NVidia GTX 970

### Issue description

First time I've had this happen, but figured I'd report it just in case.  Was dragging something onto a scene and got this crash:

Exception thrown at 0x02C44B33 in godot.windows.opt.tools.32.exe: 0xC0000005: Access violation writing location 0x00000000.

Callstack:
```
 	godot.windows.opt.tools.32.exe!memcpy(unsigned char * dst, unsigned char * src, unsigned long count) Line 600	Unknown
>	godot.windows.opt.tools.32.exe!StreamTexture::_load_data(const String & p_path, int & tw, int & th, int & tw_custom, int & th_custom, int & flags, Ref<Image> & image, int p_size_limit) Line 599	C++
 	godot.windows.opt.tools.32.exe!StreamTexture::load(const String & p_path) Line 683	C++
 	godot.windows.opt.tools.32.exe!ResourceFormatLoaderStreamTexture::load(const String & p_path, const String & p_original_path, Error * r_error) Line 838	C++
 	godot.windows.opt.tools.32.exe!ResourceLoader::_load(const String & p_path, const String & p_original_path, const String & p_type_hint, bool p_no_cache, Error * r_error) Line 262	C++
 	godot.windows.opt.tools.32.exe!ResourceFormatImporter::load(const String & p_path, const String & p_original_path, Error * r_error) Line 131	C++
 	godot.windows.opt.tools.32.exe!ResourceLoader::_load(const String & p_path, const String & p_original_path, const String & p_type_hint, bool p_no_cache, Error * r_error) Line 262	C++
 	godot.windows.opt.tools.32.exe!ResourceLoader::load(const String & p_path, const String & p_type_hint, bool p_no_cache, Error * r_error) Line 376	C++
 	godot.windows.opt.tools.32.exe!ResourceInteractiveLoaderText::poll() Line 406	C++
 	godot.windows.opt.tools.32.exe!ResourceFormatLoader::load(const String & p_path, const String & p_original_path, Error * r_error) Line 195	C++
 	godot.windows.opt.tools.32.exe!ResourceLoader::_load(const String & p_path, const String & p_original_path, const String & p_type_hint, bool p_no_cache, Error * r_error) Line 262	C++
 	godot.windows.opt.tools.32.exe!ResourceLoader::load(const String & p_path, const String & p_type_hint, bool p_no_cache, Error * r_error) Line 376	C++
 	godot.windows.opt.tools.32.exe!ResourceInteractiveLoaderText::poll() Line 406	C++
 	godot.windows.opt.tools.32.exe!ResourceFormatLoader::load(const String & p_path, const String & p_original_path, Error * r_error) Line 195	C++
 	godot.windows.opt.tools.32.exe!ResourceLoader::_load(const String & p_path, const String & p_original_path, const String & p_type_hint, bool p_no_cache, Error * r_error) Line 262	C++
 	godot.windows.opt.tools.32.exe!ResourceLoader::load(const String & p_path, const String & p_type_hint, bool p_no_cache, Error * r_error) Line 376	C++
 	godot.windows.opt.tools.32.exe!SpatialEditorViewport::can_drop_data_fw(const Vector2 & p_point, const Variant & p_data, Control * p_from) Line 3788	C++
 	godot.windows.opt.tools.32.exe!MethodBind3RC<SpatialEditorViewport,bool,Vector2 const &,Variant const &,Control *>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Variant::CallError & r_error) Line 3009	C++
 	godot.windows.opt.tools.32.exe!Object::call(const StringName & p_method, const Variant * * p_args, int p_argcount, Variant::CallError & r_error) Line 918	C++
 	godot.windows.opt.tools.32.exe!Object::call(const StringName & p_name, const Variant & p_arg1, const Variant & p_arg2, const Variant & p_arg3, const Variant & p_arg4, const Variant & p_arg5) Line 849	C++
 	godot.windows.opt.tools.32.exe!Control::can_drop_data(const Vector2 & p_point, const Variant & p_data) Line 710	C++
 	godot.windows.opt.tools.32.exe!Viewport::_gui_drop(Control * p_at_control, Vector2 p_at_pos, bool p_just_check) Line 1810	C++
 	godot.windows.opt.tools.32.exe!Viewport::_gui_input_event(Ref<InputEvent> p_event) Line 2281	C++
 	godot.windows.opt.tools.32.exe!Viewport::input(const Ref<InputEvent> & p_event) Line 2846	C++
 	godot.windows.opt.tools.32.exe!Viewport::_vp_input(const Ref<InputEvent> & p_ev) Line 1412	C++
 	godot.windows.opt.tools.32.exe!MethodBind1<Viewport,Ref<InputEvent> const &>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Variant::CallError & r_error) Line 867	C++
 	godot.windows.opt.tools.32.exe!Object::call(const StringName & p_method, const Variant * * p_args, int p_argcount, Variant::CallError & r_error) Line 918	C++
 	godot.windows.opt.tools.32.exe!Object::call(const StringName & p_name, const Variant & p_arg1, const Variant & p_arg2, const Variant & p_arg3, const Variant & p_arg4, const Variant & p_arg5) Line 849	C++
 	godot.windows.opt.tools.32.exe!SceneTree::call_group_flags(unsigned int p_call_flags, const StringName & p_group, const StringName & p_function, const Variant & p_arg1, const Variant & p_arg2, const Variant & p_arg3, const Variant & p_arg4, const Variant & p_arg5) Line 280	C++
 	godot.windows.opt.tools.32.exe!SceneTree::input_event(const Ref<InputEvent> & p_event) Line 439	C++
 	godot.windows.opt.tools.32.exe!InputDefault::_parse_input_event_impl(const Ref<InputEvent> & p_event, bool p_is_emulated) Line 491	C++
 	godot.windows.opt.tools.32.exe!InputDefault::flush_buffered_events() Line 711	C++
 	[Inline Frame] godot.windows.opt.tools.32.exe!OS_Windows::process_events() Line 2566	C++
 	godot.windows.opt.tools.32.exe!OS_Windows::run() Line 3396	C++
 	godot.windows.opt.tools.32.exe!widechar_main(int argc, wchar_t * * argv) Line 161	C++
 	godot.windows.opt.tools.32.exe!_main() Line 183	C++
 	godot.windows.opt.tools.32.exe!main(int _argc, char * * _argv) Line 195	C++
 	[External Code]	
 	kernel32.dll![Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	Unknown
```
Crashed in this memcpy:
```
			PoolVector<uint8_t> img_data;
			img_data.resize(total_size);

			{
				PoolVector<uint8_t>::Write w = img_data.write();

				int ofs = 0;
				for (int i = 0; i < mipmap_images.size(); i++) {
					PoolVector<uint8_t> id = mipmap_images[i]->get_data();
					int len = id.size();
					PoolVector<uint8_t>::Read r = id.read();
					memcpy(&w[ofs], r.ptr(), len);
					ofs += len;
				}
			}
```

Some additional info:
```
ofs is 0
mipmap_images.size() is 13 (data looked fine)
len = 67108864
Somehow total_size is 0, so I think that's the problem.  No room to write to w:
  | Name | Value | Type
-- | -- | -- | --
◢ | img_data | {[size]=89478484 [0]=??? [1]=??? ...} | PoolVector<unsigned char>
  | [size] | 89478484 | unsigned int
  | [0] | <Unable to read memory> | unsigned char
  | [1] | <Unable to read memory> | unsigned char
  | [2] | <Unable to read memory> | unsigned char
  | [3] | <Unable to read memory> | unsigned char
  | [4] | <Unable to read memory> | unsigned char
  | [5] | <Unable to read memory> | unsigned char
  | [6] | <Unable to read memory> | unsigned char
  | [7] | <Unable to read memory> | unsigned char
  | [8] | <Unable to read memory> | unsigned char
  | [9] | <Unable to read memory> | unsigned char
  | [10] | <Unable to read memory> | unsigned char
````


### Steps to reproduce

Only had it happen once (so far), but it was from dragging a scene from the content list to the scene tree list.
Edit: Here's a video clip of the crash:
https://clips.twitch.tv/BlindingEndearingSoybeanHeyGuys-LUPoRu-o6S3w7Wo7

My computer was acting very screwy, like there was some sort of resource leak, so it's entirely possible this isn't a Godot problem.  A brief look at task manager:
https://clips.twitch.tv/ShortRockyWaterNotLikeThis-x0P2CMZeN76Z-dKZ


### Minimal reproduction project

_No response_