pixz icon indicating copy to clipboard operation
pixz copied to clipboard

Fixed typo in block_alloc

Open zedseven opened this issue 4 years ago • 3 comments

In write.c Line 263, parts is compared against BLOCK_IN despite dealing with output, and the corresponding block_dealloc checks BLOCK_OUT instead. Is this a typo?

static void block_alloc(io_block_t *ib, block_parts parts) {
    if ((parts & BLOCK_IN) && !ib->input)
        ib->input = malloc(gBlockInSize);
    if ((parts & BLOCK_IN) && !ib->output) // <-- I believe this line should be BLOCK_OUT
        ib->output = malloc(gBlockOutSize);
    if (!ib->input || !ib->output)
        die("Can't allocate blocks");
}

The corresponding block_dealloc:

static void block_dealloc(io_block_t *ib, block_parts parts) {
    if (parts & BLOCK_IN) {
        free(ib->input);
        ib->input = NULL;
    }
    if (parts & BLOCK_OUT) { // <-- Uses BLOCK_OUT
        free(ib->output);
        ib->output = NULL;
    }
}

zedseven avatar Mar 19 '21 02:03 zedseven

That looks correct! Not sure what's wrong with CI though.

vasi avatar Mar 22 '21 18:03 vasi

Yeah, the CI failure is real, I can reproduce with make check locally. Can you?

vasi avatar Mar 28 '21 22:03 vasi

Is this a bug users should be worried about?

satmandu avatar May 05 '21 23:05 satmandu