Skip to content

Commit e8a87b4

Browse files
committed
Simplify comment on malloc fix
1 parent b0dcd70 commit e8a87b4

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/coreneuron/io/output_spikes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ static void output_spikes_parallel(const char* outpath, const SpikesInfo& spikes
218218
size_t num_spikes = spikevec_gid.size();
219219
size_t num_bytes = (sizeof(char) * num_spikes * SPIKE_RECORD_LEN);
220220

221-
// Allocate at least 1 byte to avoid undefined behavior from malloc(0)
222-
// followed by strcpy (triggers FORTIFY_SOURCE buffer overflow on Linux).
221+
// ensure space for at least the null terminator when there are no spikes
223222
char* spike_data = (char*) malloc(std::max(num_bytes, (size_t) 1));
224223

225224
if (spike_data == nullptr) {

0 commit comments

Comments
 (0)