--- a/contrib/chg/chg.c Wed Jun 13 14:28:39 2018 -0700
+++ b/contrib/chg/chg.c Thu Jun 14 20:09:54 2018 +0900
@@ -220,7 +220,10 @@
const char **argv = mallocx(sizeof(char *) * argsize);
memcpy(argv, baseargv, sizeof(baseargv));
- memcpy(argv + baseargvsize, opts->args, sizeof(char *) * opts->argsize);
+ if (opts->args) {
+ size_t size = sizeof(char *) * opts->argsize;
+ memcpy(argv + baseargvsize, opts->args, size);
+ }
argv[argsize - 1] = NULL;
if (putenv("CHGINTERNALMARK=") != 0)
--- a/mercurial/cext/bdiff.c Wed Jun 13 14:28:39 2018 -0700
+++ b/mercurial/cext/bdiff.c Thu Jun 14 20:09:54 2018 +0900
@@ -155,12 +155,8 @@
PyEval_RestoreThread(_save);
PyBuffer_Release(&ba);
PyBuffer_Release(&bb);
- if (al) {
- free(al);
- }
- if (bl) {
- free(bl);
- }
+ free(al);
+ free(bl);
if (l.next) {
bdiff_freehunks(l.next);
}
--- a/mercurial/cext/manifest.c Wed Jun 13 14:28:39 2018 -0700
+++ b/mercurial/cext/manifest.c Thu Jun 14 20:09:54 2018 +0900
@@ -185,15 +185,13 @@
{
/* free any extra lines we had to allocate */
int i;
- for (i = 0; i < self->numlines; i++) {
+ for (i = 0; self->lines && (i < self->numlines); i++) {
if (self->lines[i].from_malloc) {
free(self->lines[i].start);
}
}
- if (self->lines) {
- free(self->lines);
- self->lines = NULL;
- }
+ free(self->lines);
+ self->lines = NULL;
if (self->pydata) {
Py_DECREF(self->pydata);
self->pydata = NULL;
--- a/mercurial/cext/revlog.c Wed Jun 13 14:28:39 2018 -0700
+++ b/mercurial/cext/revlog.c Thu Jun 14 20:09:54 2018 +0900
@@ -333,10 +333,8 @@
PyMem_Free(self->offsets);
self->offsets = NULL;
}
- if (self->nt) {
- free(self->nt);
- self->nt = NULL;
- }
+ free(self->nt);
+ self->nt = NULL;
Py_CLEAR(self->headrevs);
}