|
21 | 21 | // |
22 | 22 | //****************************************************************************************************** |
23 | 23 |
|
| 24 | +#pragma warning(disable:26444) |
| 25 | +// ReSharper disable CppExpressionWithoutSideEffects |
24 | 26 | // ReSharper disable once CppUnusedIncludeDirective |
25 | 27 | #include "../filterexpressions/FilterExpressions.h" |
26 | 28 | #include "DataRow.h" |
@@ -470,13 +472,16 @@ void DataRow::SetValue(const int32_t columnIndex, const Nullable<T>& value, Data |
470 | 472 | if (value.HasValue()) |
471 | 473 | { |
472 | 474 | uint8_t* copy = static_cast<uint8_t*>(malloc(sizeof(T))); |
473 | | - memcpy(copy, &value.Value, sizeof(T)); //-V575 |
474 | | - m_values[columnIndex] = copy; |
475 | | - } |
476 | | - else |
477 | | - { |
478 | | - m_values[columnIndex] = nullptr; |
| 475 | + |
| 476 | + if (copy) |
| 477 | + { |
| 478 | + memcpy(copy, &value.Value, sizeof(T)); //-V575 |
| 479 | + m_values[columnIndex] = copy; |
| 480 | + return; |
| 481 | + } |
479 | 482 | } |
| 483 | + |
| 484 | + m_values[columnIndex] = nullptr; |
480 | 485 | } |
481 | 486 |
|
482 | 487 | const DataTablePtr& DataRow::Parent() const |
@@ -632,13 +637,16 @@ void DataRow::SetStringValue(const int32_t columnIndex, const Nullable<string>& |
632 | 637 | const string& strval = value.GetValueOrDefault(); |
633 | 638 | const uint32_t length = ConvertUInt32(strval.size() + 1); |
634 | 639 | char* copy = static_cast<char*>(malloc(length * sizeof(char))); |
635 | | - strcpy_s(copy, length, strval.c_str()); |
636 | | - m_values[columnIndex] = copy; |
637 | | - } |
638 | | - else |
639 | | - { |
640 | | - m_values[columnIndex] = nullptr; |
| 640 | + |
| 641 | + if (copy) |
| 642 | + { |
| 643 | + strcpy_s(copy, length, strval.c_str()); |
| 644 | + m_values[columnIndex] = copy; |
| 645 | + return; |
| 646 | + } |
641 | 647 | } |
| 648 | + |
| 649 | + m_values[columnIndex] = nullptr; |
642 | 650 | } |
643 | 651 |
|
644 | 652 | void DataRow::SetStringValue(const string& columnName, const Nullable<string>& value) |
@@ -676,13 +684,16 @@ void DataRow::SetBooleanValue(const int32_t columnIndex, const Nullable<bool>& v |
676 | 684 | if (value.HasValue()) |
677 | 685 | { |
678 | 686 | uint8_t* copy = static_cast<uint8_t*>(malloc(1)); |
679 | | - *copy = value.GetValueOrDefault() ? 1 : 0; //-V522 |
680 | | - m_values[columnIndex] = copy; |
681 | | - } |
682 | | - else |
683 | | - { |
684 | | - m_values[columnIndex] = nullptr; |
| 687 | + |
| 688 | + if (copy) |
| 689 | + { |
| 690 | + *copy = value.GetValueOrDefault() ? 1 : 0; //-V522 |
| 691 | + m_values[columnIndex] = copy; |
| 692 | + return; |
| 693 | + } |
685 | 694 | } |
| 695 | + |
| 696 | + m_values[columnIndex] = nullptr; |
686 | 697 | } |
687 | 698 |
|
688 | 699 | void DataRow::SetBooleanValue(const string& columnName, const Nullable<bool>& value) |
@@ -784,13 +795,16 @@ void DataRow::SetDecimalValue(const int32_t columnIndex, const Nullable<decimal_ |
784 | 795 | const string& strval = value.GetValueOrDefault().str(); |
785 | 796 | const uint32_t length = ConvertUInt32(strval.size() + 1); |
786 | 797 | char* copy = static_cast<char*>(malloc(length * sizeof(char))); |
787 | | - strcpy_s(copy, length, strval.c_str()); |
788 | | - m_values[columnIndex] = copy; |
789 | | - } |
790 | | - else |
791 | | - { |
792 | | - m_values[columnIndex] = nullptr; |
| 798 | + |
| 799 | + if (copy) |
| 800 | + { |
| 801 | + strcpy_s(copy, length, strval.c_str()); |
| 802 | + m_values[columnIndex] = copy; |
| 803 | + return; |
| 804 | + } |
793 | 805 | } |
| 806 | + |
| 807 | + m_values[columnIndex] = nullptr; |
794 | 808 | } |
795 | 809 |
|
796 | 810 | void DataRow::SetDecimalValue(const string& columnName, const Nullable<decimal_t>& value) |
@@ -832,13 +846,16 @@ void DataRow::SetGuidValue(const int32_t columnIndex, const Nullable<sttp::Guid> |
832 | 846 | if (value.HasValue()) |
833 | 847 | { |
834 | 848 | int8_t* copy = static_cast<int8_t*>(malloc(16)); |
835 | | - memcpy(copy, value.GetValueOrDefault().data, 16); //-V575 |
836 | | - m_values[columnIndex] = copy; |
837 | | - } |
838 | | - else |
839 | | - { |
840 | | - m_values[columnIndex] = nullptr; |
| 849 | + |
| 850 | + if (copy) |
| 851 | + { |
| 852 | + memcpy(copy, value.GetValueOrDefault().data, 16); //-V575 |
| 853 | + m_values[columnIndex] = copy; |
| 854 | + return; |
| 855 | + } |
841 | 856 | } |
| 857 | + |
| 858 | + m_values[columnIndex] = nullptr; |
842 | 859 | } |
843 | 860 |
|
844 | 861 | void DataRow::SetGuidValue(const string& columnName, const Nullable<sttp::Guid>& value) |
|
0 commit comments