You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2014/01/28 21:06:39 UTC

svn commit: r1562210 - /subversion/branches/fsfs-ucsnorm/subversion/libsvn_fs_fs/temp_serializer.c

Author: brane
Date: Tue Jan 28 20:06:39 2014
New Revision: 1562210

URL: http://svn.apache.org/r1562210
Log:
On the fsfs-ucsnorm branch: Fix crashes in fs-test.

* subversion/libsvn_fs_fs/temp_serializer.c
  (serialize_dir_entry):
   Serialize a NULL key if it's the same as the entry name,
   not an empty string; and remove the now-unused local variable.
  (find_entry): If the entry key is NULL, use the dirent name
   as the comparison key.
  (deserialize_dir, svn_fs_fs__extract_dir_entry):
   Check only for a null entry key, not an empty string.

Modified:
    subversion/branches/fsfs-ucsnorm/subversion/libsvn_fs_fs/temp_serializer.c

Modified: subversion/branches/fsfs-ucsnorm/subversion/libsvn_fs_fs/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-ucsnorm/subversion/libsvn_fs_fs/temp_serializer.c?rev=1562210&r1=1562209&r2=1562210&view=diff
==============================================================================
--- subversion/branches/fsfs-ucsnorm/subversion/libsvn_fs_fs/temp_serializer.c (original)
+++ subversion/branches/fsfs-ucsnorm/subversion/libsvn_fs_fs/temp_serializer.c Tue Jan 28 20:06:39 2014
@@ -182,7 +182,6 @@ serialize_dir_entry(svn_temp_serializer_
                     svn_fs_fs__dirent_t **entry_p,
                     apr_uint32_t *length)
 {
-  static const char *const empty = "";
   svn_fs_fs__dirent_t *entry = *entry_p;
   apr_size_t initial_length = svn_temp_serializer__get_length(context);
 
@@ -193,12 +192,12 @@ serialize_dir_entry(svn_temp_serializer_
   svn_temp_serializer__add_string(context, &entry->dirent.name);
 
   /* Serialize the key. If it's the same as the dirent name, we'll
-     store an empty string instead, as a signal to the
+     store a null pointer instead instead, as a signal to the
      deserializer. */
   if (entry->key != entry->dirent.name)
     svn_temp_serializer__add_string(context, &entry->key);
   else
-    svn_temp_serializer__add_string(context, &empty);
+    svn_temp_serializer__set_null(context, &entry->key);
 
   *length = (apr_uint32_t)(  svn_temp_serializer__get_length(context)
                            - APR_ALIGN_DEFAULT(initial_length));
@@ -290,7 +289,7 @@ deserialize_dir(void *buffer, dir_data_t
       svn_fs_fs__id_deserialize(entry, (svn_fs_id_t **)&entry->dirent.id);
 
       /* fix up the entry key */
-      if (!(entry->key && *entry->key))
+      if (!entry->key)
         entry->key = entry->dirent.name;
 
       /* add the entry to the hash */
@@ -791,8 +790,12 @@ find_entry(svn_fs_fs__dirent_t **entries
       const char* entry_key =
         svn_temp_deserializer__ptr(entry, (const void *const *)&entry->key);
 
-      int diff = strcmp(entry_key, key);
-      if (diff < 0)
+      /* use the name if it's identical to the key */
+      if (!entry_key)
+        entry_key = svn_temp_deserializer__ptr(
+            entry, (const void *const *)&entry->dirent.name);
+
+      if (0 >= strcmp(entry_key, key))
         lower = middle + 1;
       else
         upper = middle;
@@ -808,6 +811,11 @@ find_entry(svn_fs_fs__dirent_t **entries
       const char* entry_key =
         svn_temp_deserializer__ptr(entry, (const void *const *)&entry->key);
 
+      /* use the name if it's identical to the key */
+      if (!entry_key)
+        entry_key = svn_temp_deserializer__ptr(
+            entry, (const void *const *)&entry->dirent.name);
+
       *found = (strcmp(entry_key, key) == 0);
     }
 
@@ -864,7 +872,7 @@ svn_fs_fs__extract_dir_entry(void **out,
       svn_fs_fs__id_deserialize(new_entry, (svn_fs_id_t **)&new_entry->dirent.id);
 
       /* fix up the entry key */
-      if (!(new_entry->key && *new_entry->key))
+      if (!new_entry->key)
         new_entry->key = new_entry->dirent.name;
 
       *(svn_fs_fs__dirent_t **)out = new_entry;