From 6ec2014052119b9f1a874755b3bb586fc96bf9e5 Mon Sep 17 00:00:00 2001 From: Guido Reina Date: Sun, 26 May 2013 18:04:46 +0200 Subject: [PATCH 1/6] dst->length is set again afterwards. --- lib/BasicsC/structures.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/BasicsC/structures.c b/lib/BasicsC/structures.c index 965ebdfe9e..f87f13b8e1 100644 --- a/lib/BasicsC/structures.c +++ b/lib/BasicsC/structures.c @@ -89,8 +89,6 @@ TRI_blob_t* TRI_CopyBlob (TRI_memory_zone_t* zone, TRI_blob_t const* src) { return NULL; } - dst->length = src->length; - if (src->length == 0 || src->data == NULL) { dst->length = 0; dst->data = NULL; @@ -115,8 +113,6 @@ TRI_blob_t* TRI_CopyBlob (TRI_memory_zone_t* zone, TRI_blob_t const* src) { //////////////////////////////////////////////////////////////////////////////// int TRI_CopyToBlob (TRI_memory_zone_t* zone, TRI_blob_t* dst, TRI_blob_t const* src) { - dst->length = src->length; - if (src->length == 0 || src->data == NULL) { dst->length = 0; dst->data = NULL; From 0331ff7993d97e0e49124731cb8301efd192f6d2 Mon Sep 17 00:00:00 2001 From: Guido Reina Date: Sun, 26 May 2013 18:16:36 +0200 Subject: [PATCH 2/6] Typo. --- lib/BasicsC/win-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/BasicsC/win-utils.c b/lib/BasicsC/win-utils.c index 4749d8c351..1e9fe5189f 100644 --- a/lib/BasicsC/win-utils.c +++ b/lib/BasicsC/win-utils.c @@ -45,7 +45,7 @@ // ............................................................................. -// Some global variables which may be required throughtout the lifetime of the +// Some global variables which may be required throughout the lifetime of the // server // ............................................................................. From 7decf1560ac7693d479b3ad5de325f8abeec65b9 Mon Sep 17 00:00:00 2001 From: Guido Reina Date: Sun, 26 May 2013 18:44:35 +0200 Subject: [PATCH 3/6] TRI_CreateRecursiveDirectory returns an int, but the function prototype says it returns a bool (the return code is not checked in the source code, so it is not a problem). --- lib/BasicsC/files.c | 2 +- lib/BasicsC/files.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/BasicsC/files.c b/lib/BasicsC/files.c index 68607c6e57..6f07bb27f0 100644 --- a/lib/BasicsC/files.c +++ b/lib/BasicsC/files.c @@ -385,7 +385,7 @@ bool TRI_ExistsFile (char const* path) { /// @brief creates a directory, recursively //////////////////////////////////////////////////////////////////////////////// -bool TRI_CreateRecursiveDirectory (char const* path) { +int TRI_CreateRecursiveDirectory (char const* path) { char* copy; char* p; char* s; diff --git a/lib/BasicsC/files.h b/lib/BasicsC/files.h index 99d1da5199..bc056c36c3 100644 --- a/lib/BasicsC/files.h +++ b/lib/BasicsC/files.h @@ -91,7 +91,7 @@ bool TRI_ExistsFile (char const* path); /// @brief creates a directory, recursively //////////////////////////////////////////////////////////////////////////////// -bool TRI_CreateRecursiveDirectory (char const* path); +int TRI_CreateRecursiveDirectory (char const* path); //////////////////////////////////////////////////////////////////////////////// /// @brief creates a directory From a371aac4afff00c2684498a6e2ff9b2b8e498d98 Mon Sep 17 00:00:00 2001 From: Guido Reina Date: Tue, 13 Aug 2013 20:02:25 +0200 Subject: [PATCH 4/6] In the function TRI_StringInt8InPlace, when attr == INT8_MIN, it was copying only 4 bytes instead of 5 and it was returning 3 instead of 4. --- lib/BasicsC/conversions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/BasicsC/conversions.c b/lib/BasicsC/conversions.c index fa5c51b062..4ea31ccded 100644 --- a/lib/BasicsC/conversions.c +++ b/lib/BasicsC/conversions.c @@ -379,8 +379,8 @@ size_t TRI_StringInt8InPlace (int8_t attr, char* buffer) { char* p; if (attr == INT8_MIN) { - memcpy(buffer, "-128\0", 4); - return 3; + memcpy(buffer, "-128\0", 5); + return 4; } p = buffer; From 72c88473245dde33ce8cd59d2b979ace99e00dc6 Mon Sep 17 00:00:00 2001 From: Guido Reina Date: Thu, 15 Aug 2013 18:36:41 +0200 Subject: [PATCH 5/6] In the function: RemoveAllLockedFiles(void), if we call TRI_RemoveVectorString() and TRI_RemoveVector() the next elements in the vector will be memmoved to the left. The next iteration of the loop will check the element at position 1 (but we are skipping the new element at position 0), so these calls have been removed. The other alternative would be to have a loop: while (FileNames._length > 0) and take always the element at position 0. But this has the disadvantage that we are performing memmove() when later the vectors will be freed anyway. --- lib/BasicsC/files.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/BasicsC/files.c b/lib/BasicsC/files.c index 81c75eef50..c0ea0d8900 100644 --- a/lib/BasicsC/files.c +++ b/lib/BasicsC/files.c @@ -179,12 +179,10 @@ static void RemoveAllLockedFiles (void) { for (i = 0; i < FileNames._length; i++) { TRI_UnlinkFile(FileNames._buffer[i]); - TRI_RemoveVectorString(&FileNames, i); fd = * (int*) TRI_AtVector(&FileDescriptors, i); TRI_CLOSE(fd); - TRI_RemoveVector(&FileDescriptors, i); } TRI_DestroyVectorString(&FileNames); From 011117edee0b3cc81ecfd9cee65800f3684148a9 Mon Sep 17 00:00:00 2001 From: Guido Reina Date: Fri, 16 Aug 2013 06:55:43 +0200 Subject: [PATCH 6/6] In the function: TRI_LocateBinaryPath(), "binaryPath" was duplicated from "dir" and then "dir" freed. Better just to assign to "binaryPath" the result of TRI_Dirname(). --- lib/BasicsC/files.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/BasicsC/files.c b/lib/BasicsC/files.c index c0ea0d8900..bbf1b3581b 100644 --- a/lib/BasicsC/files.c +++ b/lib/BasicsC/files.c @@ -1490,7 +1490,6 @@ char* TRI_GetAbsolutePath (char const* file, char const* cwd) { char* TRI_LocateBinaryPath (char const* argv0) { char const* p; - char* dir; char* binaryPath = NULL; size_t i; @@ -1502,15 +1501,11 @@ char* TRI_LocateBinaryPath (char const* argv0) { // contains a path if (*p) { - dir = TRI_Dirname(argv0); + binaryPath = TRI_Dirname(argv0); - if (dir == 0) { + if (binaryPath == 0) { binaryPath = TRI_DuplicateString(""); } - else { - binaryPath = TRI_DuplicateString(dir); - TRI_FreeString(TRI_CORE_MEM_ZONE, dir); - } } // check PATH variable