rem: if (image->info->max_y < curr_net->stop_x)
add: if (image->info->max_y < curr_net->stop_y)
context: parse_gerb(gerb_file_t *fd){    gerb_state_t *state = NULL;    gerb_image_t *image = NULL;    gerb_net_t *curr_net = NULL;    char read;    double x_scale = 0.0, y_scale = 0.0;    double delta_cp_x = 0.0, delta_cp_y = 0.0;    int error = 0;        state = (gerb_state_t *)malloc(sizeof(gerb_state_t));    if (state == NULL)	err(1, "malloc state failed\n");    memset((void *)state, 0, sizeof(gerb_state_t));    image = new_gerb_image(image);    if (image == NULL)	err(1, "malloc image failed\n");    curr_net = image->netlist;    while ((read = gerb_fgetc(fd)) != EOF) {	switch (read) {	case 'G':	    parse_G_code(fd, state, image->format);	    break;	case 'D':	    parse_D_code(fd, state);	    break;	case 'M':	    switch(parse_M_code(fd)) {	    case 1 :	    case 2 :	    case 3 :		free(state);		/*		 * Do error check before returning image		 */		error = check_gerb(image);		if (error) {		    fprintf(stderr, "Parse error : ");		    if (error & 1)			fprintf(stderr, "Missing netlist ");		    if (error & 2)			fprintf(stderr, "Missing format ");		    if (error & 4) 			fprintf(stderr, "Missing apertures ");		    if (error & 8)			fprintf(stderr, "Missing info ");		    fprintf(stderr, "\n");		}		return image;		break;	    default:		err(1, "Strange M code found.\n");	    }	    break;	case 'X':	    state->curr_x = gerb_fgetint(fd);	    state->changed = 1;	    break;	case 'Y':	    state->curr_y = gerb_fgetint(fd);	    state->changed = 1;	    break;	case 'I':	    state->delta_cp_x = gerb_fgetint(fd);	    state->changed = 1;	    break;	case 'J':	    state->delta_cp_y = gerb_fgetint(fd);	    state->changed = 1;	    break;	case '%':	    parse_rs274x(fd, image);	    while (gerb_fgetc(fd) != '%');	    break;	case '*':	    if (state->changed == 0) break;	    state->changed = 0;	    if ( (state->curr_aperture == 0) &&		 (state->interpolation != PAREA_START) &&		 (state->interpolation != PAREA_FILL) &&		 (state->interpolation != PAREA_END) ) break;	    curr_net->next = (gerb_net_t *)malloc(sizeof(gerb_net_t));	    curr_net = curr_net->next;	    memset((void *)curr_net, 0, sizeof(gerb_net_t));	    	    /*	     * Scale to given coordinate format	     * XXX only "omit leading zeros".	     */	    if (image && image->format ){		x_scale = pow(10.0, (double)image->format->x_dec);		y_scale = pow(10.0, (double)image->format->y_dec);	    }	    	    curr_net->start_x = (double)state->prev_x / x_scale;	    curr_net->start_y = (double)state->prev_y / y_scale;	    curr_net->stop_x = (double)state->curr_x / x_scale;	    curr_net->stop_y = (double)state->curr_y / y_scale;	    delta_cp_x = (double)state->delta_cp_x / x_scale;	    delta_cp_y = (double)state->delta_cp_y / y_scale;	    switch (state->interpolation) {	    case CW_CIRCULAR :		curr_net->cirseg = (gerb_cirseg_t *)malloc(sizeof(gerb_cirseg_t));		memset((void *)curr_net->cirseg, 0, sizeof(gerb_cirseg_t));		calc_cirseg_sq(curr_net, 1, delta_cp_x, delta_cp_y);		break;	    case CCW_CIRCULAR :		curr_net->cirseg = (gerb_cirseg_t *)malloc(sizeof(gerb_cirseg_t));		memset((void *)curr_net->cirseg, 0, sizeof(gerb_cirseg_t));		calc_cirseg_sq(curr_net, 0, delta_cp_x, delta_cp_y);		break;	    case MQ_CW_CIRCULAR :		curr_net->cirseg = (gerb_cirseg_t *)malloc(sizeof(gerb_cirseg_t));		memset((void *)curr_net->cirseg, 0, sizeof(gerb_cirseg_t));		calc_cirseg_mq(curr_net, 1, delta_cp_x, delta_cp_y);		break;	    case MQ_CCW_CIRCULAR:		curr_net->cirseg = (gerb_cirseg_t *)malloc(sizeof(gerb_cirseg_t));		memset((void *)curr_net->cirseg, 0, sizeof(gerb_cirseg_t));		calc_cirseg_mq(curr_net, 0, delta_cp_x, delta_cp_y);		break;	    default :	    }#ifdef EAGLECAD_KLUDGE	    if ( (state->delta_cp_x == 0.0) && (state->delta_cp_y == 0.0) &&		 (state->interpolation != PAREA_START) &&		 (state->interpolation != PAREA_FILL) &&		 (state->interpolation != PAREA_END)  )		curr_net->interpolation = LINEARx1;	    else		curr_net->interpolation = state->interpolation;#else	    curr_net->interpolation = state->interpolation;#endif	    switch (state->interpolation) {	    case PAREA_START :		state->interpolation = PAREA_FILL;		state->changed = 1;		break;	    case PAREA_END :		state->interpolation = state->prev_interpolation;		break;	    default :	    }	    state->delta_cp_x = 0.0;	    state->delta_cp_y = 0.0;	    curr_net->aperture = state->curr_aperture;	    curr_net->aperture_state = state->aperture_state;	    	    /*	     * Find min and max of image	     */	    if (image->info->min_x == 0.0 || 		image->info->min_x > curr_net->stop_x)		image->info->min_x = curr_net->stop_x;	    if (image->info->min_y == 0.0 || 		image->info->min_y > curr_net->stop_y)		image->info->min_y = curr_net->stop_y;	    if (image->info->max_x < curr_net->stop_x)		image->info->max_x = curr_net->stop_x;	    if (image->info->max_y < curr_net->stop_x)		image->info->max_y = curr_net->stop_y;	    	    state->prev_x = state->curr_x;	    state->prev_y = state->curr_y;	    	    break;	case 10 :   /* White space */	case 13 :	case ' ' :	case '\t' :	    break;	default:	    fprintf(stderr, "Found unknown character (whitespace?) %c[%d]\n", read, read);	}    }        fprintf(stderr, "File is missing gerber End-Of-File\n");        return image;} /* parse_gerb */