Index: trunk/src/obj_arc.c =================================================================== --- trunk/src/obj_arc.c (revision 28843) +++ trunk/src/obj_arc.c (revision 28844) @@ -404,8 +404,14 @@ pcb_layer_t *srcly = arc->parent.layer; assert(arc->parent_type == PCB_PARENT_LAYER); - if ((dstly == NULL) || (dstly == srcly)) /* auto layer in dst */ - dstly = &ctx->buffer.dst->Layer[pcb_layer_id(ctx->buffer.src, srcly)]; + if ((dstly == NULL) || (dstly == srcly)) { /* auto layer in dst */ + pcb_layer_id_t lid = pcb_layer_id(ctx->buffer.src, srcly); + if (lid < 0) { + pcb_message(PCB_MSG_ERROR, "Internal error: can't resolve source layer ID in pcb_arcop_move_buffer\n"); + return NULL; + } + dstly = &ctx->buffer.dst->Layer[lid]; + } pcb_poly_restore_to_poly(ctx->buffer.src, PCB_OBJ_ARC, srcly, arc); pcb_r_delete_entry(srcly->arc_tree, (pcb_box_t *) arc); Index: trunk/src/obj_line.c =================================================================== --- trunk/src/obj_line.c (revision 28843) +++ trunk/src/obj_line.c (revision 28844) @@ -445,8 +445,14 @@ pcb_layer_t *srcly = line->parent.layer; assert(line->parent_type == PCB_PARENT_LAYER); - if ((dstly == NULL) || (dstly == srcly)) /* auto layer in dst */ - dstly = &ctx->buffer.dst->Layer[pcb_layer_id(ctx->buffer.src, srcly)]; + if ((dstly == NULL) || (dstly == srcly)) { /* auto layer in dst */ + pcb_layer_id_t lid = pcb_layer_id(ctx->buffer.src, srcly); + if (lid < 0) { + pcb_message(PCB_MSG_ERROR, "Internal error: can't resolve source layer ID in pcb_lineop_move_buffer\n"); + return NULL; + } + dstly = &ctx->buffer.dst->Layer[lid]; + } pcb_poly_restore_to_poly(ctx->buffer.src, PCB_OBJ_LINE, srcly, line); pcb_r_delete_entry(srcly->line_tree, (pcb_box_t *)line); Index: trunk/src/obj_poly.c =================================================================== --- trunk/src/obj_poly.c (revision 28843) +++ trunk/src/obj_poly.c (revision 28844) @@ -536,8 +536,14 @@ pcb_layer_t *srcly = polygon->parent.layer; assert(polygon->parent_type == PCB_PARENT_LAYER); - if ((dstly == NULL) || (dstly == srcly)) /* auto layer in dst */ - dstly = &ctx->buffer.dst->Layer[pcb_layer_id(ctx->buffer.src, srcly)]; + if ((dstly == NULL) || (dstly == srcly)) { /* auto layer in dst */ + pcb_layer_id_t lid = pcb_layer_id(ctx->buffer.src, srcly); + if (lid < 0) { + pcb_message(PCB_MSG_ERROR, "Internal error: can't resolve source layer ID in pcb_polyop_move_buffer\n"); + return NULL; + } + dstly = &ctx->buffer.dst->Layer[lid]; + } pcb_poly_pprestore(polygon); Index: trunk/src/obj_text.c =================================================================== --- trunk/src/obj_text.c (revision 28843) +++ trunk/src/obj_text.c (revision 28844) @@ -438,8 +438,14 @@ pcb_layer_t *srcly = text->parent.layer; assert(text->parent_type == PCB_PARENT_LAYER); - if ((dstly == NULL) || (dstly == srcly)) /* auto layer in dst */ - dstly = &ctx->buffer.dst->Layer[pcb_layer_id(ctx->buffer.src, srcly)]; + if ((dstly == NULL) || (dstly == srcly)) { /* auto layer in dst */ + pcb_layer_id_t lid = pcb_layer_id(ctx->buffer.src, srcly); + if (lid < 0) { + pcb_message(PCB_MSG_ERROR, "Internal error: can't resolve source layer ID in pcb_textop_move_buffer\n"); + return NULL; + } + dstly = &ctx->buffer.dst->Layer[lid]; + } pcb_r_delete_entry(srcly->text_tree, (pcb_box_t *) text); pcb_poly_restore_to_poly(ctx->buffer.src, PCB_OBJ_TEXT, srcly, text);