package com.google.firebase.encoders.proto;

import java.io.OutputStream;

/* loaded from: classes3.dex */
final class LengthCountingOutputStream extends OutputStream {
    private long length = 0;

    /* JADX INFO: Access modifiers changed from: package-private */
    public long getLength() {
        return this.length;
    }

    @Override // java.io.OutputStream
    public void write(int i10) {
        this.length++;
    }

    @Override // java.io.OutputStream
    public void write(byte[] bArr) {
        this.length += bArr.length;
    }

    @Override // java.io.OutputStream
    public void write(byte[] bArr, int i10, int i11) {
        int i12;
        if (i10 >= 0 && i10 <= bArr.length && i11 >= 0 && (i12 = i10 + i11) <= bArr.length && i12 >= 0) {
            this.length += i11;
            return;
        }
        throw new IndexOutOfBoundsException();
    }
}
