summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2012-07-26 15:05:24 +0200
committerTor Didriksen <tor.didriksen@oracle.com>2012-07-26 15:05:24 +0200
commitd24a78d1ea2b07cd1b3863190b371c7c8ea39a3c (patch)
tree13406385bf3c6fabf58dbaf27ded8ac0101ef9a4 /client
parentaef1982be0a5ff5bd25fb7658d8792fd9ab40c3f (diff)
downloadmariadb-git-d24a78d1ea2b07cd1b3863190b371c7c8ea39a3c.tar.gz
Backport of Bug#14171740 65562: STRING::SHRINK SHOULD BE A NO-OP WHEN ALLOCED=0
Diffstat (limited to 'client')
-rw-r--r--client/sql_string.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/client/sql_string.h b/client/sql_string.h
index 020bf78a6de..57d4d196e8c 100644
--- a/client/sql_string.h
+++ b/client/sql_string.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -195,8 +195,12 @@ public:
}
bool real_alloc(uint32 arg_length); // Empties old string
bool realloc(uint32 arg_length);
- inline void shrink(uint32 arg_length) // Shrink buffer
+
+ // Shrink the buffer, but only if it is allocated on the heap.
+ inline void shrink(uint32 arg_length)
{
+ if (!is_alloced())
+ return;
if (arg_length < Alloced_length)
{
char *new_ptr;
@@ -212,7 +216,7 @@ public:
}
}
}
- bool is_alloced() { return alloced; }
+ bool is_alloced() const { return alloced; }
inline String& operator = (const String &s)
{
if (&s != this)