Crash when connecting hierarchical label to net with existing label

Description

It looks like add multiple labels within a hierarchical sheet will lead to crashes, when one of the included labels is a "plain" label or a hierarchical label.

Steps to reproduce

  1. Create a schematic with a hierarchical sheet
  2. Draw a wire, and connect a label to it (any type)
  3. Attempt to connect a second label (hierarchical or plain) to the wire: KiCAD will crash

image

KiCad Version

Application: KiCad x64 on x64

Version: 8.0.5, release build

Libraries:
	wxWidgets 3.2.5
	FreeType 2.13.2
	HarfBuzz 9.0.0
	FontConfig 2.14.2
	libcurl/8.8.0-DEV Schannel zlib/1.3.1

Platform: Windows 11 (build 22631), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
	Date: Sep  7 2024 02:39:48
	wxWidgets: 3.2.5 (wchar_t,wx containers)
	Boost: 1.85.0
	OCC: 7.8.1
	Curl: 8.8.0-DEV
	ngspice: 42
	Compiler: Visual C++ 1939 without C++ ABI

Build settings: