Skip to content

Commit

Permalink
Make sure buffer size is more than 0
Browse files Browse the repository at this point in the history
This is an attempt to fix a data corruption issue, that manifests in a
random byte replacing a correct one in a pickle.
  • Loading branch information
kedder committed May 9, 2019
1 parent aa2f39a commit 4193367
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/zodbpickle/_pickle_33.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ _Pickler_Write(PicklerObject *self, const char *s, Py_ssize_t n)
PyErr_NoMemory();
return -1;
}
self->max_output_len = (self->output_len + n) / 2 * 3;
self->max_output_len = (self->output_len + n) / 2 * 3 + 1;
if (_PyBytes_Resize(&self->output_buffer, self->max_output_len) < 0)
return -1;
}
Expand Down

0 comments on commit 4193367

Please sign in to comment.