• oystein.grovlen@sun.com's avatar
    Bug#52168 decimal casting catastrophes: crashes and valgrind errors on simple casts · 80fc19ad
    oystein.grovlen@sun.com authored
    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.
    80fc19ad
item.cc 224 KB