c
int safe_modulo(int dividend, int divisor) {
    if (divisor == 0) {
        TIFFErrorExt(tif->tif_clientdata, module,
                     "Invalid JPEG sampling factor or DCT size");
        return (0);
    }
    return dividend % divisor;
}

if (safe_modulo(td->td_tilelength, sp->v_sampling * DCTSIZE) != 0) {
    TIFFErrorExt(tif->tif_clientdata, module,
                 "JPEG tile height must be multiple of %d",
                 sp->v_sampling * DCTSIZE);
    return (0);
}
