diff options
author | oystein.grovlen@sun.com <> | 2010-05-28 17:30:39 +0200 |
---|---|---|
committer | oystein.grovlen@sun.com <> | 2010-05-28 17:30:39 +0200 |
commit | 80fc19ade7fd66f82d5ad0be69c8c7815020b590 (patch) | |
tree | 33c6a6b8ab8950c484744de565554274b321c321 /sql/item.h | |
parent | 507621cec80e1fa41f188af3d1d5b37390abddc2 (diff) | |
download | mariadb-git-80fc19ade7fd66f82d5ad0be69c8c7815020b590.tar.gz |
Bug#52168 decimal casting catastrophes: crashes and valgrind errors on simple casts
The problem is that if a NULL is stored in an Item_cache_decimal object,
the associated my_decimal object is not initialized. However, it is still
accessed when val_int() is called. The fix is to check for null_value
within val_int(), and return without accessing the my_decimal object when
the cached value is NULL.
Bug#52122 reports the same issue for val_real(), and this patch also includes
fixes for val_real() and val_str() and corresponding test cases from that
bug report.
Also, NULL is returned from val_decimal() when value is null. This will
avoid that callers access an uninitialized my_decimal object.
Made similar changes to all other Item_cache classes. Now all val_*
methods should return a well defined value when actual value is NULL.
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/item.h b/sql/item.h index 5f4f96f97d3..8360fa61498 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3191,6 +3191,15 @@ public: { return this == item; } + /** + Check if saved item has a non-NULL value. + Will cache value of saved item if not already done. + @return TRUE if cached value is non-NULL. + */ + bool has_value() + { + return (value_cached || cache_value()) && !null_value; + } virtual void store(Item *item); virtual bool cache_value()= 0; bool basic_const_item() const |