summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-12-07 17:01:58 -0500
committerAdam <Adam@anope.org>2010-12-07 17:01:58 -0500
commit2b7dd6c2a023186aefe12eaee7d33595379bf4c5 (patch)
tree712274ce279d5a8fc08cd6538fbe2fbbf2f3ad52
parentc5fc11f5fe92b31200dc6cf542514b1ffeb70c44 (diff)
Fixed some warnings found by cppcheck
-rw-r--r--include/version.sh.c4
-rw-r--r--lang/langcomp.c4
-rw-r--r--src/config.c6
-rw-r--r--src/misc.c2
-rw-r--r--src/modules.c4
-rw-r--r--src/modules/extra/atheme2anope/atheme2anope.c2
-rw-r--r--src/modules/ns_noop_convert.c1
-rw-r--r--src/mypasql.c3
-rw-r--r--src/nickserv.c3
-rw-r--r--version.log3
10 files changed, 23 insertions, 9 deletions
diff --git a/include/version.sh.c b/include/version.sh.c
index 0610a8e83..08106d536 100644
--- a/include/version.sh.c
+++ b/include/version.sh.c
@@ -161,6 +161,8 @@ void write_version(FILE * fd)
char buf[1024];
short until_eof = 0;
+ if (!fdin)
+ return;
while (fgets(buf, 1023, fdin)) {
strip(buf);
@@ -173,7 +175,7 @@ void write_version(FILE * fd)
if (!strcmp(buf, "cat >version.h <<EOF"))
until_eof = 1;
}
-
+ fclose(fdin);
}
void parse_line(FILE * fd, char *line)
diff --git a/lang/langcomp.c b/lang/langcomp.c
index cdafefb4c..e221cf672 100644
--- a/lang/langcomp.c
+++ b/lang/langcomp.c
@@ -77,10 +77,12 @@ int read_index_file()
numstrings++;
if (!(stringnames = calloc(sizeof(char *), numstrings))) {
perror("calloc(stringnames)");
+ fclose(f);
return -1;
}
if (!(strings = calloc(sizeof(char *), numstrings))) {
perror("calloc(strings)");
+ fclose(f);
return -1;
}
fseek(f, 0, SEEK_SET);
@@ -90,6 +92,7 @@ int read_index_file()
buf[strlen(buf)-1] = '\0';
if (!(stringnames[i++] = anopeStrDup(buf))) {
perror("strdup()");
+ fclose(f);
return -1;
}
}
@@ -201,6 +204,7 @@ int main(int ac, char **av)
}
if (!(out = fopen(outfile, "wb"))) {
perror(outfile);
+ fclose(in);
return 1;
}
diff --git a/src/config.c b/src/config.c
index 793b608e6..5bd1cf2bd 100644
--- a/src/config.c
+++ b/src/config.c
@@ -926,7 +926,9 @@ int read_config(int reload)
perror("Can't open " SERVICES_CONF);
else
alog("Can't open %s", SERVICES_CONF);
+#ifndef NOT_MAIN
}
+#endif
return 0;
}
while (fgets(buf, sizeof(buf), config)) {
@@ -1246,7 +1248,7 @@ int read_config(int reload)
if (s) {
RootNumber++;
ServicesRoots =
- realloc(ServicesRoots, sizeof(char *) * RootNumber);
+ srealloc(ServicesRoots, sizeof(char *) * RootNumber);
ServicesRoots[RootNumber - 1] = sstrdup(s);
}
} while ((s = strtok(NULL, " ")));
@@ -1266,7 +1268,7 @@ int read_config(int reload)
do {
if (s) {
NumUlines++;
- Ulines = realloc(Ulines, sizeof(char *) * NumUlines);
+ Ulines = srealloc(Ulines, sizeof(char *) * NumUlines);
Ulines[NumUlines - 1] = sstrdup(s);
}
} while ((s = strtok(NULL, " ")));
diff --git a/src/misc.c b/src/misc.c
index f51c2697c..488d028e3 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1221,7 +1221,7 @@ char **buildStringList(char *src, int *number)
do {
if (s) {
i++;
- list = realloc(list, sizeof(char *) * i);
+ list = srealloc(list, sizeof(char *) * i);
list[i - 1] = sstrdup(s);
}
} while ((s = strtok(NULL, " ")));
diff --git a/src/modules.c b/src/modules.c
index 7e7061647..ab3352ac8 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -537,7 +537,7 @@ int moduleCopyFile(char *name, char *output)
int ch;
FILE *source, *target;
int srcfp;
- char input[4096];
+ char input[4096] = "";
int len;
strncpy(input, MODULE_PATH, 4095); /* Get full path with module extension */
@@ -562,6 +562,7 @@ int moduleCopyFile(char *name, char *output)
*/
#ifndef _WIN32
if ((source = fopen(input, "r")) == NULL) {
+ close(srcfp);
#else
if ((source = fopen(input, "rb")) == NULL) {
#endif
@@ -572,6 +573,7 @@ int moduleCopyFile(char *name, char *output)
#else
if ((target = fopen(output, "wb")) == NULL) {
#endif
+ fclose(source);
return MOD_ERR_FILE_IO;
}
while ((ch = fgetc(source)) != EOF) {
diff --git a/src/modules/extra/atheme2anope/atheme2anope.c b/src/modules/extra/atheme2anope/atheme2anope.c
index 49cbc1b1e..c0b4804ce 100644
--- a/src/modules/extra/atheme2anope/atheme2anope.c
+++ b/src/modules/extra/atheme2anope/atheme2anope.c
@@ -232,7 +232,7 @@ void WriteNick(char *line)
}
}
}
- else if (!strcmp(tok, "SO"))
+ else if (na && !strcmp(tok, "SO"))
{
tok = strtok(NULL, " ");
na->nc->flags |= NI_SERVICES_OPER;
diff --git a/src/modules/ns_noop_convert.c b/src/modules/ns_noop_convert.c
index 24abd0bb7..50c0d4021 100644
--- a/src/modules/ns_noop_convert.c
+++ b/src/modules/ns_noop_convert.c
@@ -127,6 +127,7 @@ int mLoadData(void)
free(name);
}
}
+ fclose(in);
}
return ret;
}
diff --git a/src/mypasql.c b/src/mypasql.c
index a66850c84..50e9d26cf 100644
--- a/src/mypasql.c
+++ b/src/mypasql.c
@@ -86,15 +86,16 @@ int __stdcall mysql_LoadFromFile(char *file)
add_line(&query, line);
if (mysql_real_query(mysql, query, strlen(query))) {
free(query);
+ fclose(fd);
return 0;
}
free(query);
query = NULL;
}
-
else
add_line(&query, line);
}
+ fclose(fd);
return 1;
}
diff --git a/src/nickserv.c b/src/nickserv.c
index 3cc58a868..ca1301779 100644
--- a/src/nickserv.c
+++ b/src/nickserv.c
@@ -1384,7 +1384,7 @@ void insert_core(NickCore * nc)
/*************************************************************************/
void insert_requestnick(NickRequest * nr)
{
- int index = HASH(nr->nick);
+ int index;
if (!nr) {
if (debug) {
alog("debug: insert_requestnick called with NULL values");
@@ -1392,6 +1392,7 @@ void insert_requestnick(NickRequest * nr)
return;
}
+ index = HASH(nr->nick);
nr->prev = NULL;
nr->next = nrlists[index];
diff --git a/version.log b/version.log
index 2b794748e..325d1168c 100644
--- a/version.log
+++ b/version.log
@@ -8,9 +8,10 @@ VERSION_MAJOR="1"
VERSION_MINOR="8"
VERSION_PATCH="5"
VERSION_EXTRA="-git"
-VERSION_BUILD="3046"
+VERSION_BUILD="3047"
# $Log$ # Changes since 1.8.5 Release
+#Revision 3047 - Fixed some warnings found by cppcheck
#Revision 3046 - Fixed bug #1202 - Made Anope aware of plexus3's channel mode +z
#Revision 3045 - Fixed some improper english in the HOST_GROUP language strings
#Revision 3044 - Fixed a potential crash from accessing invalid memory after unbanning people when checking whether a host is akick stuck. Fixes /cs unban not reapplying stuck ban masks.