1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-27 13:04:36 +03:00

Fix two small problems in the source, potentially causing user-visible

bugs.


ndb/include/util/UtilBuffer.hpp:
  Fix accessing memory after free(), if called with source and destination
  pointer the same (which should not really happen...).
  Fixes a problem in ndb_restore.
ndb/src/common/util/SimpleProperties.cpp:
  Fix typo in check of maxValue.
This commit is contained in:
unknown
2006-10-25 10:37:53 +02:00
parent 311abf108b
commit c6ca641a6b
2 changed files with 8 additions and 4 deletions

View File

@@ -73,11 +73,15 @@ public:
} }
int assign(const void * d, size_t l) { int assign(const void * d, size_t l) {
if (data) free(data); /* Free the old data only after copying, in case d==data. */
void *old_data= data;
data = NULL; data = NULL;
len = 0; len = 0;
alloc_size = 0; alloc_size = 0;
return append(d, l); int ret= append(d, l);
if (old_data)
free(old_data);
return ret;
} }
void clear() { void clear() {

View File

@@ -245,7 +245,7 @@ SimpleProperties::pack(Writer & it, const void * __src,
const char * src_len = _src + _map[i].Length_Offset; const char * src_len = _src + _map[i].Length_Offset;
Uint32 len = *((Uint32*)src_len); Uint32 len = *((Uint32*)src_len);
if(!ignoreMinMax){ if(!ignoreMinMax){
if(len == _map[i].maxValue) if(len > _map[i].maxValue)
return ValueTooHigh; return ValueTooHigh;
} }
ok = it.add(_map[i].Key, src, len); ok = it.add(_map[i].Key, src, len);
@@ -254,7 +254,7 @@ SimpleProperties::pack(Writer & it, const void * __src,
case SimpleProperties::StringValue: case SimpleProperties::StringValue:
if(!ignoreMinMax){ if(!ignoreMinMax){
size_t len = strlen(src); size_t len = strlen(src);
if(len == _map[i].maxValue) if(len > _map[i].maxValue)
return ValueTooHigh; return ValueTooHigh;
} }
ok = it.add(_map[i].Key, src); ok = it.add(_map[i].Key, src);