mirror of
https://github.com/samba-team/samba.git
synced 2024-12-30 13:18:05 +03:00
Fix memory leaks and add parinoioa code to our stat() cache.
Andrew Bartlett
This commit is contained in:
parent
a0208a4f74
commit
3fd07bd25e
@ -90,14 +90,28 @@ void stat_cache_add( char *full_orig_name, char *orig_translated_path)
|
||||
}
|
||||
|
||||
original_path = strdup(full_orig_name);
|
||||
if (!original_path)
|
||||
if (!original_path) {
|
||||
SAFE_FREE(translated_path);
|
||||
return;
|
||||
}
|
||||
|
||||
original_path_length = strlen(original_path);
|
||||
|
||||
if(original_path[original_path_length-1] == '/') {
|
||||
original_path[original_path_length-1] = '\0';
|
||||
original_path_length--;
|
||||
}
|
||||
|
||||
if(!case_sensitive)
|
||||
strupper(original_path);
|
||||
|
||||
|
||||
if(!(original_path_length == translated_path_length)) {
|
||||
DEBUG(0, ("OOPS - tried to store stat cache entry for non-equal length paths [%s] %u and [%s] %u)!\n", original_path, original_path_length, translated_path, translated_path_length));
|
||||
SAFE_FREE(original_path);
|
||||
SAFE_FREE(translated_path);
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* We will only replace namelen characters
|
||||
@ -119,6 +133,8 @@ void stat_cache_add( char *full_orig_name, char *orig_translated_path)
|
||||
found_scp = (stat_cache_entry *)(hash_elem->value);
|
||||
if (strcmp((found_scp->translated_path), orig_translated_path) == 0) {
|
||||
/* already in hash table */
|
||||
SAFE_FREE(original_path);
|
||||
SAFE_FREE(translated_path);
|
||||
return;
|
||||
}
|
||||
/* hash collision - remove before we re-add */
|
||||
@ -133,6 +149,8 @@ void stat_cache_add( char *full_orig_name, char *orig_translated_path)
|
||||
+original_path_length
|
||||
+translated_path_length)) == NULL) {
|
||||
DEBUG(0,("stat_cache_add: Out of memory !\n"));
|
||||
SAFE_FREE(original_path);
|
||||
SAFE_FREE(translated_path);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -144,6 +162,9 @@ void stat_cache_add( char *full_orig_name, char *orig_translated_path)
|
||||
|
||||
hash_insert(&stat_cache, (char *)scp, original_path);
|
||||
|
||||
SAFE_FREE(original_path);
|
||||
SAFE_FREE(translated_path);
|
||||
|
||||
DEBUG(5,("stat_cache_add: Added entry %s -> %s\n", scp->original_path, scp->translated_path));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user