Changeset: 3143c623b70b for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3143c623b70b Modified Files: clients/mapilib/mapi.c sql/backends/monet5/sql_result.c Branch: Oct2020 Log Message:
Fix problems found by clang-analyzer.
diffs (62 lines):
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -3359,7 +3359,6 @@ mapi_prepare(Mapi mid, const char *cmd)
free(q); \
return; \
} \
- hdl->query = q; \
} \
} while (0)
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -59,9 +59,8 @@ mnstr_swap_lng(stream *s, lng lngval) {
int neg = v < 0;
\
ssize_t l;
\
if (is_##TYPE##_nil(v)) {
\
- if (*len < 5){
\
- if (*Buf)
\
- GDKfree(*Buf);
\
+ if (*Buf == NULL || *len < 5){ \
+ GDKfree(*Buf);
\
*len = 5;
\
*Buf = GDKzalloc(*len);
\
if (*Buf == NULL) {
\
@@ -91,9 +90,8 @@ mnstr_swap_lng(stream *s, lng lngval) {
if (neg)
\
buf[cur--] = '-';
\
l = (64-cur-1);
\
- if ((ssize_t) *len < l){
\
- if (*Buf)
\
- GDKfree(*Buf);
\
+ if (*Buf == NULL || (ssize_t) *len < l) { \
+ GDKfree(*Buf);
\
*len = (size_t) l+1;
\
*Buf = GDKzalloc(*len);
\
if (*Buf == NULL) {
\
@@ -160,9 +158,8 @@ sql_time_tostr(void *TS_RES, char **buf,
return len1;
}
- if (*len < (size_t) len1 + 8) {
- if (*buf)
- GDKfree(*buf);
+ if (*buf == NULL || *len < (size_t) len1 + 8) {
+ GDKfree(*buf);
*buf = (str) GDKzalloc(*len = len1 + 8);
if (*buf == NULL) {
return -1;
@@ -220,9 +217,8 @@ sql_timestamp_tostr(void *TS_RES, char *
return len1;
}
- if (*len < (size_t) len1 + (size_t) len2 + 8) {
- if (*buf)
- GDKfree(*buf);
+ if (*buf == NULL || *len < (size_t) len1 + (size_t) len2 + 8) {
+ GDKfree(*buf);
*buf = (str) GDKzalloc(*len = (size_t) (len1 + len2 + 8));
if (*buf == NULL) {
return -1;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list
