reftable/stack: handle allocation failures in stack_compact_range()
Handle allocation failures in `stack_compact_range()`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
5dbe266212
commit
694af039f5
@ -1131,6 +1131,11 @@ static int stack_compact_range(struct reftable_stack *st,
|
|||||||
* from the point of view of the newer process.
|
* from the point of view of the newer process.
|
||||||
*/
|
*/
|
||||||
REFTABLE_CALLOC_ARRAY(table_locks, last - first + 1);
|
REFTABLE_CALLOC_ARRAY(table_locks, last - first + 1);
|
||||||
|
if (!table_locks) {
|
||||||
|
err = REFTABLE_OUT_OF_MEMORY_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = last + 1; i > first; i--) {
|
for (i = last + 1; i > first; i--) {
|
||||||
stack_filename(&table_name, st, reader_name(st->readers[i - 1]));
|
stack_filename(&table_name, st, reader_name(st->readers[i - 1]));
|
||||||
|
|
||||||
@ -1312,8 +1317,18 @@ static int stack_compact_range(struct reftable_stack *st,
|
|||||||
* thus have to allocate `readers_len + 1` many entries.
|
* thus have to allocate `readers_len + 1` many entries.
|
||||||
*/
|
*/
|
||||||
REFTABLE_CALLOC_ARRAY(names, st->merged->readers_len + 1);
|
REFTABLE_CALLOC_ARRAY(names, st->merged->readers_len + 1);
|
||||||
for (size_t i = 0; i < st->merged->readers_len; i++)
|
if (!names) {
|
||||||
names[i] = xstrdup(st->readers[i]->name);
|
err = REFTABLE_OUT_OF_MEMORY_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < st->merged->readers_len; i++) {
|
||||||
|
names[i] = reftable_strdup(st->readers[i]->name);
|
||||||
|
if (!names[i]) {
|
||||||
|
err = REFTABLE_OUT_OF_MEMORY_ERROR;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
first_to_replace = first;
|
first_to_replace = first;
|
||||||
last_to_replace = last;
|
last_to_replace = last;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user