mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-24 06:53:59 +08:00
Remove usage of uninitilized value
Function `timescaledb_CopyFrom` created a variable `errcallback` to save away the previous error callback and restoring it afterwards. However, if `ccstate->cstate` was false, the variable would not be set and the later restore of the error callback would use a random value. This commit fixes the issue by initializing `errcallback` to all zeroes and checking if a callback has been saved away before restoring it.
This commit is contained in:
parent
18c9cf1c0b
commit
d3966cead3
@ -111,7 +111,7 @@ timescaledb_CopyFrom(CopyChunkState *ccstate, List *range_table, Hypertable *ht)
|
||||
TupleTableSlot *myslot;
|
||||
MemoryContext oldcontext = CurrentMemoryContext;
|
||||
|
||||
ErrorContextCallback errcallback;
|
||||
ErrorContextCallback errcallback = { 0 };
|
||||
CommandId mycid = GetCurrentCommandId(true);
|
||||
int hi_options = 0; /* start with default heap_insert options */
|
||||
BulkInsertState bistate;
|
||||
@ -366,8 +366,10 @@ timescaledb_CopyFrom(CopyChunkState *ccstate, List *range_table, Hypertable *ht)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Done, clean up */
|
||||
error_context_stack = errcallback.previous;
|
||||
if (errcallback.previous)
|
||||
error_context_stack = errcallback.previous;
|
||||
|
||||
FreeBulkInsertState(bistate);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user