Skip to content

Commit

Permalink
v2.0.9 fixed null handling issue in remove_accents
Browse files Browse the repository at this point in the history
  • Loading branch information
iulian0512 committed Feb 9, 2024
1 parent 1f2287c commit 472c3c5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ publishing {
register<MavenPublication>("release") {
groupId = "org.spatialite"
artifactId = "spatialite"
version = "2.0.8"
version = "2.0.9"

afterEvaluate {
from(components["release"])
Expand Down
47 changes: 35 additions & 12 deletions static_libs/sqlite-amalgamation-3430200/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -212096,9 +212096,24 @@ char* remove_accents(const char* input) {


static void sqlite_remove_accents(sqlite3_context* context, int argc, sqlite3_value** argv) {
if (argc != 1 || sqlite3_value_type(argv[0]) != SQLITE_TEXT) {
sqlite3_result_error(context, "Invalid arguments", -1);
return;
if (argc != 1) // Ensure only one argument is passed
{
sqlite3_result_error(context, "remove_accents() expects only one argument", -1);
return;
}
else
{
int valueType=sqlite3_value_type(argv[0]);
if(valueType == SQLITE_NULL)
{
sqlite3_result_null(context); // Return NULL if input is NULL nothing to do
return;
}
else if(valueType != SQLITE_TEXT)
{
sqlite3_result_error(context, "Invalid arguments expecting string literal or expression that evaluates to a string", -1);
return;
}
}

const char* input = (const char*)sqlite3_value_text(argv[0]);
Expand Down Expand Up @@ -250899,8 +250914,10 @@ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
/************************** End of sqlite3.c ******************************/




#ifdef _MSC_VER
#include <wchar.h>
#include <crtdbg.h> // Required for memory leak detection functions
#include <Windows.h>
void test_remove_accents() {
struct TestCase {
const char* input;
Expand Down Expand Up @@ -250957,11 +250974,17 @@ void test_remove_accents() {
free(largeResult);
}

// int main() {
// for(int i=0;i<100;i++)
// {
// test_remove_accents();
int main() {
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
for(int i=0;i<100;i++)
{
test_remove_accents();

// }
// return 0;
// }
}

_CrtCheckMemory();
_CrtDumpMemoryLeaks();

return 0;
}
#endif

0 comments on commit 472c3c5

Please sign in to comment.