Skip to content

Commit

Permalink
fix: missing error handling, add valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
eberkund committed Jan 23, 2023
1 parent 052a495 commit 6ebc15b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
17 changes: 16 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,22 @@ ARG DEBIAN_FRONTEND="noninteractive"
SHELL ["/bin/bash", "-c"]

RUN apt-get -qq -o=Dpkg::Use-Pty=0 update \
&& apt-get -qq -o=Dpkg::Use-Pty=0 install git boxes clang clangd clang-format make cmake libssl-dev libuv1-dev zlib1g-dev libluajit-5.1-dev luajit luarocks pkg-config \
&& apt-get -qq -o=Dpkg::Use-Pty=0 install \
git \
boxes \
clang \
clangd \
clang-format \
make \
cmake \
libssl-dev \
libuv1-dev \
zlib1g-dev \
libluajit-5.1-dev \
luajit \
luarocks \
pkg-config \
valgrind \
&& apt-get clean \
&& wget -q https://github.com/JohnnyMorganz/StyLua/releases/download/v0.16.0/stylua-linux.zip \
&& unzip stylua-linux.zip -d /usr/bin \
Expand Down
41 changes: 38 additions & 3 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,60 +399,95 @@ LucasError *cass_value_to_lua(lua_State *L, const CassValue *cass_value)
}
else if (vt == CASS_VALUE_TYPE_ASCII || vt == CASS_VALUE_TYPE_TEXT || vt == CASS_VALUE_TYPE_VARCHAR)
{
const char *value = NULL;
size_t length = 0;
const char *value;
size_t length;
err = cass_value_get_string(cass_value, &value, &length);
if (err != CASS_OK)
{
goto cleanup;
}
lua_pushlstring(L, value, length);
}
else if (vt == CASS_VALUE_TYPE_UUID || vt == CASS_VALUE_TYPE_TIMEUUID)
{
CassUuid value;
char value_as_string[CASS_UUID_STRING_LENGTH];
err = cass_value_get_uuid(cass_value, &value);
if (err != CASS_OK)
{
goto cleanup;
}
cass_uuid_string(value, value_as_string);
lua_pushstring(L, value_as_string);
}
else if (vt == CASS_VALUE_TYPE_TINY_INT)
{
cass_int8_t value;
err = cass_value_get_int8(cass_value, &value);
if (err != CASS_OK)
{
goto cleanup;
}
lua_pushinteger(L, value);
}
else if (vt == CASS_VALUE_TYPE_SMALL_INT)
{
cass_int16_t value;
err = cass_value_get_int16(cass_value, &value);
if (err != CASS_OK)
{
goto cleanup;
}
lua_pushinteger(L, value);
}
else if (vt == CASS_VALUE_TYPE_INT)
{
cass_int32_t value;
err = cass_value_get_int32(cass_value, &value);
if (err != CASS_OK)
{
goto cleanup;
}
lua_pushinteger(L, value);
}
else if (vt == CASS_VALUE_TYPE_BIGINT || vt == CASS_VALUE_TYPE_TIMESTAMP || vt == CASS_VALUE_TYPE_COUNTER ||
vt == CASS_VALUE_TYPE_TIME)
{
cass_int64_t value;
err = cass_value_get_int64(cass_value, &value);
if (err != CASS_OK)
{
goto cleanup;
}
lua_pushinteger(L, value);
}
else if (vt == CASS_VALUE_TYPE_BOOLEAN)
{
cass_bool_t value;
err = cass_value_get_bool(cass_value, &value);
if (cass_value_get_bool(cass_value, &value) != CASS_OK)
{
goto cleanup;
}
lua_pushboolean(L, value);
}
else if (vt == CASS_VALUE_TYPE_FLOAT)
{
cass_float_t value;
err = cass_value_get_float(cass_value, &value);
if (err != CASS_OK)
{
goto cleanup;
}
lua_pushnumber(L, value);
}
else if (vt == CASS_VALUE_TYPE_DOUBLE)
{
cass_double_t value;
err = cass_value_get_double(cass_value, &value);
if (err != CASS_OK)
{
goto cleanup;
}
lua_pushnumber(L, value);
}
else if (vt == CASS_VALUE_TYPE_MAP)
Expand Down

0 comments on commit 6ebc15b

Please sign in to comment.