- usb_descriptors = AO_USB_DESCRIPTORS - image->address;
- string_num = 0;
- while (image->data[usb_descriptors] != 0 && usb_descriptors < image->length) {
- if (image->data[usb_descriptors+1] == AO_USB_DESC_STRING) {
- ++string_num;
- if (string_num == 4)
- break;
+ if (AO_USB_DESCRIPTORS) {
+ unsigned usb_descriptors;
+ usb_descriptors = AO_USB_DESCRIPTORS - image->address;
+ string_num = 0;
+ while (image->data[usb_descriptors] != 0 && usb_descriptors < image->length) {
+ if (image->data[usb_descriptors+1] == AO_USB_DESC_STRING) {
+ ++string_num;
+ if (string_num == 4)
+ break;
+ }
+ usb_descriptors += image->data[usb_descriptors];
+ }
+ if (usb_descriptors >= image->length || image->data[usb_descriptors] == 0 ) {
+ fprintf(stderr, "Cannot rewrite serial string at %04x\n", AO_USB_DESCRIPTORS);
+ exit(1);