Changeset: 101be7fb4bcc for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=101be7fb4bcc Modified Files: clients/mapiclient/ReadlineTools.c clients/mapiclient/dump.c clients/mapiclient/tomograph.c clients/odbc/driver/SQLColumnPrivileges.c clients/odbc/driver/SQLColumns.c clients/odbc/driver/SQLPrepare.c clients/odbc/driver/SQLPrimaryKeys.c clients/odbc/driver/SQLProcedures.c clients/odbc/driver/SQLSpecialColumns.c clients/odbc/driver/SQLStatistics.c clients/odbc/driver/SQLTablePrivileges.c common/stream/stream.c geom/monetdb5/geom.c Branch: default Log Message:
Merge with Jan2014 branch. diffs (truncated from 370 to 300 lines): diff --git a/clients/mapiclient/ReadlineTools.c b/clients/mapiclient/ReadlineTools.c --- a/clients/mapiclient/ReadlineTools.c +++ b/clients/mapiclient/ReadlineTools.c @@ -92,8 +92,9 @@ sql_tablename_generator(const char *text while (seekpos < rowcount) { const char *name; - mapi_seek_row(table_hdl, seekpos++, MAPI_SEEK_SET); - mapi_fetch_row(table_hdl); + if (mapi_seek_row(table_hdl, seekpos++, MAPI_SEEK_SET) != MOK || + mapi_fetch_row(table_hdl) <= 0) + continue; name = mapi_fetch_field(table_hdl, 0); if (strncmp(name, text, len) == 0) { char *s; diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c --- a/clients/mapiclient/dump.c +++ b/clients/mapiclient/dump.c @@ -1833,8 +1833,6 @@ dump_database(Mapi mid, stream *toConsol return rc; bailout: - if( curschema ) - free(curschema); if (hdl) { if (mapi_result_error(hdl)) mapi_explain_result(hdl, stderr); @@ -1845,6 +1843,8 @@ dump_database(Mapi mid, stream *toConsol mapi_explain(mid, stderr); bailout2: + if (curschema) + free(curschema); hdl = mapi_query(mid, end); if (hdl) mapi_close_handle(hdl); diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c --- a/clients/mapiclient/tomograph.c +++ b/clients/mapiclient/tomograph.c @@ -1106,7 +1106,10 @@ showcolormap(char *filename, int all) if (all) { snprintf(buf, BUFSIZ, "%s.gpl", filename); f = fopen(buf, "w"); - assert(f); + if (f == NULL) { + fprintf(stderr, "Creating file %s.gpl failed\n", filename); + exit(1); + } fprintf(f, "set terminal pdfcairo noenhanced color solid size 8.3, 11.7\n"); fprintf(f, "set output \"%s.pdf\"\n", filename); fprintf(f, "set size 1,1\n"); @@ -1237,6 +1240,10 @@ showcolormap(char *filename, int all) fprintf(f, "\" at %d,%d\n", (int) (0.2 * w), h - 35); fprintf(f, "plot 0 notitle with lines linecolor rgb \"white\"\n"); + if (all) { + assert(f != gnudata); + fclose(f); + } } static void @@ -1296,7 +1303,10 @@ keepdata(char *filename) return; snprintf(buf, BUFSIZ, "%s.trace", filename); f = fopen(buf, "w"); - assert(f); + if (f == NULL) { + fprintf(stderr, "Creating file %s.trace failed\n", filename); + exit(1); + } for (i = 0; i < topbox; i++) if (box[i].clkend && box[i].fcn) { @@ -1855,8 +1865,10 @@ parser(char *row) /* find genuine function calls */ while (isspace((int) *fcn) && *fcn) fcn++; - if (strchr(fcn, '.') == 0) + if (strchr(fcn, '.') == 0) { + free(stmt); return -10; + } } else { fcn = strchr(fcn, '"'); if (fcn) { @@ -2149,6 +2161,10 @@ stop_cleanup: doQ("profiler.stop();"); doQ("profiler.closeStream();"); stop_disconnect: + if (dbhsql) { + mapi_disconnect(dbhsql); + mapi_destroy(dbhsql); + } if (wthr->dbh) { mapi_disconnect(wthr->dbh); mapi_destroy(wthr->dbh); diff --git a/clients/odbc/driver/SQLColumnPrivileges.c b/clients/odbc/driver/SQLColumnPrivileges.c --- a/clients/odbc/driver/SQLColumnPrivileges.c +++ b/clients/odbc/driver/SQLColumnPrivileges.c @@ -234,6 +234,7 @@ SQLColumnPrivileges_(ODBCStmt *stmt, return rc; nomem: + /* note that query must be NULL when we get here */ if (cat) free(cat); if (sch) @@ -242,8 +243,6 @@ SQLColumnPrivileges_(ODBCStmt *stmt, free(tab); if (col) free(col); - if (query) - free(query); /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); return SQL_ERROR; diff --git a/clients/odbc/driver/SQLColumns.c b/clients/odbc/driver/SQLColumns.c --- a/clients/odbc/driver/SQLColumns.c +++ b/clients/odbc/driver/SQLColumns.c @@ -531,6 +531,7 @@ SQLColumns_(ODBCStmt *stmt, return rc; nomem: + /* note that query must be NULL when we get here */ if (cat) free(cat); if (sch) @@ -539,8 +540,6 @@ SQLColumns_(ODBCStmt *stmt, free(tab); if (col) free(col); - if (query) - free(query); /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); return SQL_ERROR; diff --git a/clients/odbc/driver/SQLPrepare.c b/clients/odbc/driver/SQLPrepare.c --- a/clients/odbc/driver/SQLPrepare.c +++ b/clients/odbc/driver/SQLPrepare.c @@ -178,8 +178,9 @@ SQLPrepare_(ODBCStmt *stmt, if (rec->sql_desc_schema_name) { /* base table name and base column * name exist if there is a schema - * name */ - rec->sql_desc_base_table_name = (SQLCHAR *) strdup((char *) rec->sql_desc_table_name); + * name; the extra check is for static + * code analyzers and robustness */ + rec->sql_desc_base_table_name = rec->sql_desc_table_name ? (SQLCHAR *) strdup((char *) rec->sql_desc_table_name) : NULL; rec->sql_desc_base_column_name = (SQLCHAR *) strdup((char *) rec->sql_desc_name); } else { rec->sql_desc_base_table_name = NULL; diff --git a/clients/odbc/driver/SQLPrimaryKeys.c b/clients/odbc/driver/SQLPrimaryKeys.c --- a/clients/odbc/driver/SQLPrimaryKeys.c +++ b/clients/odbc/driver/SQLPrimaryKeys.c @@ -190,14 +190,13 @@ SQLPrimaryKeys_(ODBCStmt *stmt, return rc; nomem: + /* note that query must be NULL when we get here */ if (cat) free(cat); if (sch) free(sch); if (tab) free(tab); - if (query) - free(query); /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); return SQL_ERROR; diff --git a/clients/odbc/driver/SQLProcedures.c b/clients/odbc/driver/SQLProcedures.c --- a/clients/odbc/driver/SQLProcedures.c +++ b/clients/odbc/driver/SQLProcedures.c @@ -194,14 +194,13 @@ SQLProcedures_(ODBCStmt *stmt, return rc; nomem: + /* note that query must be NULL when we get here */ if (cat) free(cat); if (sch) free(sch); if (pro) free(pro); - if (query) - free(query); /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); return SQL_ERROR; diff --git a/clients/odbc/driver/SQLSpecialColumns.c b/clients/odbc/driver/SQLSpecialColumns.c --- a/clients/odbc/driver/SQLSpecialColumns.c +++ b/clients/odbc/driver/SQLSpecialColumns.c @@ -518,6 +518,8 @@ SQLSpecialColumns_(ODBCStmt *stmt, "cast(0 as smallint) as decimal_digits, " "cast(0 as smallint) as pseudo_column " "where 0 = 1"); + if (query == NULL) + goto nomem; query_end = query + strlen(query); } @@ -531,14 +533,13 @@ SQLSpecialColumns_(ODBCStmt *stmt, return rc; nomem: + /* note that query must be NULL when we get here */ if (cat) free(cat); if (sch) free(sch); if (tab) free(tab); - if (query) - free(query); /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); return SQL_ERROR; diff --git a/clients/odbc/driver/SQLStatistics.c b/clients/odbc/driver/SQLStatistics.c --- a/clients/odbc/driver/SQLStatistics.c +++ b/clients/odbc/driver/SQLStatistics.c @@ -276,14 +276,13 @@ SQLStatistics_(ODBCStmt *stmt, return rc; nomem: + /* note that query must be NULL when we get here */ if (cat) free(cat); if (sch) free(sch); if (tab) free(tab); - if (query) - free(query); /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); return SQL_ERROR; diff --git a/clients/odbc/driver/SQLTablePrivileges.c b/clients/odbc/driver/SQLTablePrivileges.c --- a/clients/odbc/driver/SQLTablePrivileges.c +++ b/clients/odbc/driver/SQLTablePrivileges.c @@ -208,14 +208,13 @@ SQLTablePrivileges_(ODBCStmt *stmt, return rc; nomem: + /* note that query must be NULL when we get here */ if (cat) free(cat); if (sch) free(sch); if (tab) free(tab); - if (query) - free(query); /* Memory allocation error */ addStmtError(stmt, "HY001", NULL, 0); return SQL_ERROR; diff --git a/common/stream/stream.c b/common/stream/stream.c --- a/common/stream/stream.c +++ b/common/stream/stream.c @@ -749,8 +749,12 @@ open_stream(const char *filename, const if (file_read(s, buf, 1, UTF8BOMLENGTH) == UTF8BOMLENGTH && strncmp(buf, UTF8BOM, UTF8BOMLENGTH) == 0) s->isutf8 = 1; - else - file_fsetpos(s, pos); + else if (file_fsetpos(s, pos) < 0) { + /* unlikely: we couldn't seek the file back */ + fclose(fp); + destroy(s); + return NULL; + } } return s; } @@ -1035,6 +1039,11 @@ open_bzstream(const char *filename, cons free(bzp); return NULL; } + s->read = stream_bzread; + s->write = stream_bzwrite; + s->close = stream_bzclose; + s->flush = NULL; + s->stream_data.p = (void *) bzp; if (strchr(flags, 'r') != NULL) { bzp->b = BZ2_bzReadOpen(&err, bzp->f, 0, 0, NULL, 0); s->access = ST_READ; @@ -1051,11 +1060,6 @@ open_bzstream(const char *filename, cons destroy(s); return NULL; } - s->read = stream_bzread; - s->write = stream_bzwrite; - s->close = stream_bzclose; - s->flush = NULL; - s->stream_data.p = (void *) bzp; return s; } @@ -1681,9 +1685,9 @@ socket_update_timeout(stream *s) tv.tv_usec = (s->timeout % 1000) * 1000; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list