aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>2011-03-23 14:14:30 +0000
committerFrank Warmerdam <warmerdam@pobox.com>2011-03-23 14:14:30 +0000
commitba0403ec4ef2a67579c6ccd0b581202dbc1a9f95 (patch)
tree12a3af314e35999412c4960c5f7f1965c448b5e7 /src
parent7327ac23c34e92debfd8ef21c872559eb26b16c3 (diff)
downloadPROJ-ba0403ec4ef2a67579c6ccd0b581202dbc1a9f95.tar.gz
PROJ-ba0403ec4ef2a67579c6ccd0b581202dbc1a9f95.zip
fix reversed memcpy that triggers crash on 16th cached item (#100)
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@1988 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src')
-rw-r--r--src/pj_initcache.c124
1 files changed, 62 insertions, 62 deletions
diff --git a/src/pj_initcache.c b/src/pj_initcache.c
index 5dd46fad..71036f23 100644
--- a/src/pj_initcache.c
+++ b/src/pj_initcache.c
@@ -75,34 +75,34 @@ paralist *pj_clone_paralist( const paralist *list)
void pj_clear_initcache()
{
- if( cache_alloc > 0 )
- {
- int i;
+ if( cache_alloc > 0 )
+ {
+ int i;
- pj_acquire_lock();
+ pj_acquire_lock();
- for( i = 0; i < cache_count; i++ )
- {
- paralist *n, *t = cache_paralist[i];
+ for( i = 0; i < cache_count; i++ )
+ {
+ paralist *n, *t = cache_paralist[i];
- pj_dalloc( cache_key[i] );
-
- /* free parameter list elements */
- for (; t != NULL; t = n) {
- n = t->next;
- pj_dalloc(t);
- }
- }
-
- pj_dalloc( cache_key );
- pj_dalloc( cache_paralist );
- cache_count = 0;
- cache_alloc= 0;
- cache_key = NULL;
- cache_paralist = NULL;
-
- pj_release_lock();
- }
+ pj_dalloc( cache_key[i] );
+
+ /* free parameter list elements */
+ for (; t != NULL; t = n) {
+ n = t->next;
+ pj_dalloc(t);
+ }
+ }
+
+ pj_dalloc( cache_key );
+ pj_dalloc( cache_paralist );
+ cache_count = 0;
+ cache_alloc= 0;
+ cache_key = NULL;
+ cache_paralist = NULL;
+
+ pj_release_lock();
+ }
}
/************************************************************************/
@@ -114,22 +114,22 @@ void pj_clear_initcache()
paralist *pj_search_initcache( const char *filekey )
{
- int i;
- paralist *result = NULL;
+ int i;
+ paralist *result = NULL;
- pj_acquire_lock();
+ pj_acquire_lock();
- for( i = 0; result == NULL && i < cache_count; i++)
+ for( i = 0; result == NULL && i < cache_count; i++)
{
- if( strcmp(filekey,cache_key[i]) == 0 )
+ if( strcmp(filekey,cache_key[i]) == 0 )
{
- result = pj_clone_paralist( cache_paralist[i] );
+ result = pj_clone_paralist( cache_paralist[i] );
}
}
- pj_release_lock();
+ pj_release_lock();
- return result;
+ return result;
}
/************************************************************************/
@@ -141,41 +141,41 @@ paralist *pj_search_initcache( const char *filekey )
void pj_insert_initcache( const char *filekey, const paralist *list )
{
- pj_acquire_lock();
+ pj_acquire_lock();
- /*
- ** Grow list if required.
- */
- if( cache_count == cache_alloc )
+ /*
+ ** Grow list if required.
+ */
+ if( cache_count == cache_alloc )
{
- char **cache_key_new;
- paralist **cache_paralist_new;
-
- cache_alloc = cache_alloc * 2 + 15;
-
- cache_key_new = (char **) pj_malloc(sizeof(char*) * cache_alloc);
- memcpy( cache_key, cache_key_new, sizeof(char*) * cache_count);
- pj_dalloc( cache_key );
- cache_key = cache_key_new;
-
- cache_paralist_new = (paralist **)
- pj_malloc(sizeof(paralist*) * cache_alloc);
- memcpy( cache_paralist_new, cache_paralist,
- sizeof(paralist*) * cache_count );
- pj_dalloc( cache_paralist );
- cache_paralist = cache_paralist_new;
+ char **cache_key_new;
+ paralist **cache_paralist_new;
+
+ cache_alloc = cache_alloc * 2 + 15;
+
+ cache_key_new = (char **) pj_malloc(sizeof(char*) * cache_alloc);
+ memcpy( cache_key_new, cache_key, sizeof(char*) * cache_count);
+ pj_dalloc( cache_key );
+ cache_key = cache_key_new;
+
+ cache_paralist_new = (paralist **)
+ pj_malloc(sizeof(paralist*) * cache_alloc);
+ memcpy( cache_paralist_new, cache_paralist,
+ sizeof(paralist*) * cache_count );
+ pj_dalloc( cache_paralist );
+ cache_paralist = cache_paralist_new;
}
- /*
- ** Duplicate the filekey and paralist, and insert in cache.
- */
- cache_key[cache_count] = (char *) pj_malloc(strlen(filekey)+1);
- strcpy( cache_key[cache_count], filekey );
+ /*
+ ** Duplicate the filekey and paralist, and insert in cache.
+ */
+ cache_key[cache_count] = (char *) pj_malloc(strlen(filekey)+1);
+ strcpy( cache_key[cache_count], filekey );
- cache_paralist[cache_count] = pj_clone_paralist( list );
+ cache_paralist[cache_count] = pj_clone_paralist( list );
- cache_count++;
+ cache_count++;
- pj_release_lock();
+ pj_release_lock();
}