Fix various minor issues discovered with static analysis using Visual Studio 2005 Team System.
Removed obsolete comment, since .dll modules are no longer supported on windows, only .pyd.
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 4f7d1f1..dd9887b 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -533,11 +533,12 @@
self->buf_size = size;
}
else if (n > self->buf_size) {
- self->buf = (char *)realloc(self->buf, n);
- if (!self->buf) {
+ char *newbuf = (char *)realloc(self->buf, n);
+ if (!newbuf) {
PyErr_NoMemory();
return -1;
}
+ self->buf = newbuf;
self->buf_size = n;
}
@@ -576,6 +577,7 @@
i = 0;
while (1) {
int bigger;
+ char *newbuf;
for (; i < (self->buf_size - 1); i++) {
if (feof(self->fp) ||
(self->buf[i] = getc(self->fp)) == '\n') {
@@ -589,11 +591,12 @@
PyErr_NoMemory();
return -1;
}
- self->buf = (char *)realloc(self->buf, bigger);
- if (!self->buf) {
+ newbuf = (char *)realloc(self->buf, bigger);
+ if (!newbuf) {
PyErr_NoMemory();
return -1;
}
+ self->buf = newbuf;
self->buf_size = bigger;
}
}
@@ -4365,17 +4368,19 @@
*/
if ((self->num_marks + 1) >= self->marks_size) {
+ int *marks;
s=self->marks_size+20;
if (s <= self->num_marks) s=self->num_marks + 1;
if (self->marks == NULL)
- self->marks=(int *)malloc(s * sizeof(int));
+ marks=(int *)malloc(s * sizeof(int));
else
- self->marks=(int *)realloc(self->marks,
+ marks=(int *)realloc(self->marks,
s * sizeof(int));
- if (! self->marks) {
+ if (!marks) {
PyErr_NoMemory();
return -1;
}
+ self->marks = marks;
self->marks_size = s;
}