rem: assert(x >= 0 && x < image->width); assert(y >= 0 && y < image->height);
add: if (x < 0 || x >= image->width || y < 0 || y >= image->height) return;
context: RPutPixel(RImage *image, int x, int y, RColor *color){    int ofs;    unsigned char *sr, *sg, *sb, *sa;    assert(image!=NULL);    assert(color!=NULL);    assert(x >= 0 && x < image->width);    assert(y >= 0 && y < image->height);    ofs = y*image->width + x;    sr = image->data[0] + ofs;    sg = image->data[1] + ofs;    sb = image->data[2] + ofs;    sa = image->data[3] + ofs;    if (color->alpha==255) {        *sr = color->red;        *sg = color->green;        *sb = color->blue;        if (image->data[3])            *sa = 255;    } else {        register int alpha, nalpha, r, g, b;        r = color->red;        g = color->green;        b = color->blue;        alpha = color->alpha;        nalpha = 255 - alpha;        *sr = (((int)*sr * nalpha) + (r * alpha))/256;        *sg = (((int)*sg * nalpha) + (g * alpha))/256;        *sb = (((int)*sb * nalpha) + (b * alpha))/256;        if (image->data[3])            *sa = alpha + ((int)*sa * nalpha)/256;    }}