@@ -267,7 +267,10 @@ static usb_error_t get_configuration_descriptor_handler(usb_endpoint_t endpoint,
267267 usb_device_t device = usb_GetEndpointDevice (endpoint );
268268 struct item * item = usb_GetDeviceData (device );
269269 const usb_configuration_descriptor_t * configuration_descriptor = data ;
270- item -> gui -> dirty = true;
270+ if (item && item -> gui )
271+ {
272+ item -> gui -> dirty = true;
273+ }
271274 if (item == NULL || configuration_descriptor == NULL || status != USB_TRANSFER_COMPLETED ||
272275 transferred != item -> configuration_descriptor .wTotalLength ||
273276 configuration_descriptor -> bLength < sizeof (usb_configuration_descriptor_t ) ||
@@ -292,14 +295,20 @@ static usb_error_t get_total_length_handler(usb_endpoint_t endpoint, usb_transfe
292295 item -> configuration_descriptor .bLength < transferred ||
293296 item -> configuration_descriptor .bDescriptorType != USB_CONFIGURATION_DESCRIPTOR )
294297 {
295- item -> gui -> dirty = true;
298+ if (item && item -> gui )
299+ {
300+ item -> gui -> dirty = true;
301+ }
296302 return USB_SUCCESS ;
297303 }
298304
299305 configuration_descriptor = malloc (item -> configuration_descriptor .wTotalLength );
300306 if (configuration_descriptor == NULL )
301307 {
302- item -> gui -> dirty = true;
308+ if (item && item -> gui )
309+ {
310+ item -> gui -> dirty = true;
311+ }
303312 return USB_SUCCESS ;
304313 }
305314 item -> setup .bmRequestType = USB_DEVICE_TO_HOST | USB_STANDARD_REQUEST | USB_RECIPIENT_DEVICE ;
@@ -321,7 +330,10 @@ static usb_error_t get_serial_number_handler(usb_endpoint_t endpoint, usb_transf
321330 item -> string_descriptor .bLength < 2 || item -> string_descriptor .bLength > transferred ||
322331 item -> string_descriptor .bDescriptorType != USB_STRING_DESCRIPTOR )
323332 {
324- item -> gui -> dirty = true;
333+ if (item && item -> gui )
334+ {
335+ item -> gui -> dirty = true;
336+ }
325337 return USB_SUCCESS ;
326338 }
327339 usb_string_descriptor_to_ascii (& item -> string_descriptor , item -> serial_number );
@@ -345,7 +357,10 @@ static usb_error_t get_product_handler(usb_endpoint_t endpoint, usb_transfer_sta
345357 item -> string_descriptor .bLength < 2 || item -> string_descriptor .bLength > transferred ||
346358 item -> string_descriptor .bDescriptorType != USB_STRING_DESCRIPTOR )
347359 {
348- item -> gui -> dirty = true;
360+ if (item && item -> gui )
361+ {
362+ item -> gui -> dirty = true;
363+ }
349364 return USB_SUCCESS ;
350365 }
351366 usb_string_descriptor_to_ascii (& item -> string_descriptor , item -> product );
@@ -376,7 +391,10 @@ static usb_error_t get_manufacturer_handler(usb_endpoint_t endpoint, usb_transfe
376391 item -> string_descriptor .bLength < 2 || item -> string_descriptor .bLength > transferred ||
377392 item -> string_descriptor .bDescriptorType != USB_STRING_DESCRIPTOR )
378393 {
379- item -> gui -> dirty = true;
394+ if (item && item -> gui )
395+ {
396+ item -> gui -> dirty = true;
397+ }
380398 return USB_SUCCESS ;
381399 }
382400 usb_string_descriptor_to_ascii (& item -> string_descriptor , item -> manufacturer );
@@ -415,7 +433,10 @@ static usb_error_t get_langid_handler(usb_endpoint_t endpoint, usb_transfer_stat
415433 item -> string_descriptor .bLength < transferred ||
416434 item -> string_descriptor .bDescriptorType != USB_STRING_DESCRIPTOR )
417435 {
418- item -> gui -> dirty = true;
436+ if (item && item -> gui )
437+ {
438+ item -> gui -> dirty = true;
439+ }
419440 return USB_SUCCESS ;
420441 }
421442 item -> langid = item -> string_descriptor .bString [0 ];
@@ -446,7 +467,10 @@ static usb_error_t get_device_descriptor_handler(usb_endpoint_t endpoint, usb_tr
446467 item -> device_descriptor .bLength < transferred ||
447468 item -> device_descriptor .bDescriptorType != USB_DEVICE_DESCRIPTOR )
448469 {
449- item -> gui -> dirty = true;
470+ if (item && item -> gui )
471+ {
472+ item -> gui -> dirty = true;
473+ }
450474 return USB_SUCCESS ;
451475 }
452476
@@ -464,7 +488,6 @@ static usb_error_t enabled_handler(usb_device_t device)
464488 struct item * item = usb_GetDeviceData (device );
465489 if (item == NULL )
466490 {
467- item -> gui -> dirty = true;
468491 return USB_SUCCESS ;
469492 }
470493 item -> setup .bmRequestType = USB_DEVICE_TO_HOST | USB_STANDARD_REQUEST | USB_RECIPIENT_DEVICE ;
0 commit comments