Changeset: 5e7124c49aeb for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5e7124c49aeb Modified Files: sql/backends/monet5/UDF/pyapi/convert_loops.h sql/backends/monet5/UDF/pyapi/pyapi.c Branch: Dec2016 Log Message:
Check all BUNappends.
diffs (117 lines):
diff --git a/sql/backends/monet5/UDF/pyapi/convert_loops.h
b/sql/backends/monet5/UDF/pyapi/convert_loops.h
--- a/sql/backends/monet5/UDF/pyapi/convert_loops.h
+++ b/sql/backends/monet5/UDF/pyapi/convert_loops.h
@@ -247,7 +247,10 @@
for (iu = 0; iu < ret->count; iu++)
\
{
\
snprintf(utf8_string, utf8string_minlength, fmt,
*((mtpe*)&data[(index_offset * ret->count + iu) * ret->memory_size]));
\
- BUNappend(bat, utf8_string, FALSE);
\
+ if (BUNappend(bat, utf8_string, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
}
\
}
\
else
\
@@ -257,12 +260,18 @@
if (mask[index_offset * ret->count + iu] == TRUE)
\
{
\
bat->tnil = 1;
\
- BUNappend(bat, str_nil, FALSE);
\
+ if (BUNappend(bat, str_nil, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
}
\
else
\
{
\
snprintf(utf8_string, utf8string_minlength, fmt,
*((mtpe*)&data[(index_offset * ret->count + iu) * ret->memory_size]));
\
- BUNappend(bat, utf8_string, FALSE);
\
+ if (BUNappend(bat, utf8_string, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
}
\
}
\
}
@@ -318,13 +327,19 @@
for (iu = 0; iu < ret->count; iu++) {
\
if (mask != NULL && (mask[index_offset * ret->count + iu])
== TRUE) {
\
b->tnil = 1;
\
- BUNappend(b, str_nil, FALSE);
\
+ if (BUNappend(b, str_nil, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
} else {
\
if (!string_copy(&data[(index_offset * ret->count + iu)
* ret->memory_size], utf8_string, ret->memory_size, true)) {
\
msg = createException(MAL, "pyapi.eval", "Invalid
string encoding used. Please return a regular ASCII string, or a Numpy_Unicode
object.\n"); \
goto wrapup;
\
}
\
- BUNappend(b, utf8_string, FALSE);
\
+ if (BUNappend(b, utf8_string, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
}
\
}
\
break;
\
@@ -332,10 +347,16 @@
for (iu = 0; iu < ret->count; iu++) {
\
if (mask != NULL && (mask[index_offset * ret->count + iu])
== TRUE) {
\
b->tnil = 1;
\
- BUNappend(b, str_nil, FALSE);
\
+ if (BUNappend(b, str_nil, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
} else {
\
utf32_to_utf8(0, ret->memory_size / 4, utf8_string,
(const Py_UNICODE*)(&data[(index_offset * ret->count + iu) *
ret->memory_size])); \
- BUNappend(b, utf8_string, FALSE);
\
+ if (BUNappend(b, utf8_string, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
}
\
}
\
break;
\
@@ -357,11 +378,17 @@
for (iu = 0; iu < ret->count; iu++) {
\
if (mask != NULL && (mask[index_offset * ret->count + iu])
== TRUE) {
\
b->tnil = 1;
\
- BUNappend(b, str_nil, FALSE);
\
+ if (BUNappend(b, str_nil, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
} else {
\
/* we try to handle as many types as possible */
\
pyobject_to_str(((PyObject**) &data[(index_offset *
ret->count + iu) * ret->memory_size]), utf8_size, &utf8_string);
\
- BUNappend(b, utf8_string, FALSE);
\
+ if (BUNappend(b, utf8_string, FALSE) != GDK_SUCCEED) { \
+ msg = createException(MAL, "pyapi.eval", "BUNappend
failed.\n"); \
+ goto wrapup;
\
+ }
\
}
\
}
\
break;
\
diff --git a/sql/backends/monet5/UDF/pyapi/pyapi.c
b/sql/backends/monet5/UDF/pyapi/pyapi.c
--- a/sql/backends/monet5/UDF/pyapi/pyapi.c
+++ b/sql/backends/monet5/UDF/pyapi/pyapi.c
@@ -2270,9 +2270,15 @@ str ConvertFromSQLType(BAT *b, sql_subty
int length = 0;
void *element = (void*) BUNtail(li, p);
if (strConversion(&result, &length, element) == 0) {
+ BBPunfix((*ret_bat)->batCacheid);
+ *ret_bat = NULL;
return createException(MAL, "pyapi.eval", "Failed to convert
element to string.");
}
- BUNappend(*ret_bat, result, FALSE);
+ if (BUNappend(*ret_bat, result, FALSE) != GDK_SUCCEED) {
+ BBPunfix((*ret_bat)->batCacheid);
+ *ret_bat = NULL;
+ return createException(MAL, "pyapi.eval", "BUNappend failed.");
+ }
}
return res;
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list
