[Groonga-commit] groonga/groonga at 9addc4e [master] Copy path to buffer to avoid storing a pointer to a local buffer.

Back to archive index

Genki Takiuchi null+****@clear*****
Sat Mar 3 11:51:04 JST 2018


Genki Takiuchi	2018-03-03 11:51:04 +0900 (Sat, 03 Mar 2018)

  New Revision: 9addc4e3031378b2137b223b43c2bc98abd174b4
  https://github.com/groonga/groonga/commit/9addc4e3031378b2137b223b43c2bc98abd174b4

  Merged d665a68: Merge pull request #830 from genki/fix_file_lock

  Message:
    Copy path to buffer to avoid storing a pointer to a local buffer.

  Modified files:
    lib/file_lock.c
    lib/grn_file_lock.h

  Modified: lib/file_lock.c (+2 -2)
===================================================================
--- lib/file_lock.c    2018-03-02 15:57:19 +0900 (3f00e45a9)
+++ lib/file_lock.c    2018-03-03 11:51:04 +0900 (d39bde770)
@@ -42,7 +42,7 @@ grn_file_lock_init(grn_ctx *ctx,
                    grn_file_lock *file_lock,
                    const char *path)
 {
-  file_lock->path = path;
+  grn_strcpy(file_lock->path, PATH_MAX, path);
 #ifdef WIN32
   file_lock->handle = INVALID_HANDLE_VALUE;
 #else /* WIN32 */
@@ -109,7 +109,7 @@ grn_file_lock_release(grn_ctx *ctx, grn_file_lock *file_lock)
 
   file_lock->fd = -1;
 #endif /* WIN32 */
-  file_lock->path = NULL;
+  grn_strcpy(file_lock->path, PATH_MAX, "");
 }
 
 void

  Modified: lib/grn_file_lock.h (+1 -1)
===================================================================
--- lib/grn_file_lock.h    2018-03-02 15:57:19 +0900 (43ab57633)
+++ lib/grn_file_lock.h    2018-03-03 11:51:04 +0900 (4d4f7e2fc)
@@ -25,7 +25,7 @@ extern "C" {
 #endif
 
 typedef struct {
-  const char *path;
+  char path[PATH_MAX];
 #ifdef WIN32
   HANDLE handle;
 #else /* WIN32 */
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180303/848ab2d8/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index