]> sigrok.org Git - pulseview.git/commitdiff
Session: Fix mismatched delete operator.
authorPhilipp Marek <redacted>
Fri, 17 Nov 2017 10:17:36 +0000 (11:17 +0100)
committerPhilipp Marek <redacted>
Fri, 17 Nov 2017 10:55:37 +0000 (11:55 +0100)
Valgrind reported this here:

Mismatched free() / delete / delete []
   at 0x4C2D31B: operator delete(void*) (vg_replace_malloc.c:576)
   by 0x1C76D0: operator() (unique_ptr.h:78)
   by 0x1C76D0: ~unique_ptr (unique_ptr.h:268)
   by 0x1C76D0: pv::data::AnalogSegment::append_interleaved_samples(float const*, unsigned long, unsigned long) (analogsegment.cpp:78)
   by 0x1AFDD5: pv::Session::feed_in_analog(std::shared_ptr<sigrok::Analog>) (session.cpp:1142)
   by 0x1B043C: pv::Session::data_feed_in(std::shared_ptr<sigrok::Device>, std::shared_ptr<sigrok::Packet>) (session.cpp:1187)
...
 Address 0x1cbf6b90 is 0 bytes inside a block of size 940 alloc'd
   at 0x4C2C97F: operator new[](unsigned long) (vg_replace_malloc.c:423)
   by 0x1C765E: pv::data::AnalogSegment::append_interleaved_samples(float const*, unsigned long, unsigned long) (analogsegment.cpp:78)
   by 0x1AFDD5: pv::Session::feed_in_analog(std::shared_ptr<sigrok::Analog>) (session.cpp:1142)

pv/session.cpp

index dd06cfed360a2bd6a45e65577d2441e30404639e..b9612d0e04f3b3a02f84dc55c4a6c3d4ae823d86 100644 (file)
@@ -1097,7 +1097,7 @@ void Session::feed_in_analog(shared_ptr<Analog> analog)
        const size_t sample_count = analog->num_samples() / channel_count;
        bool sweep_beginning = false;
 
-       unique_ptr<float> data(new float[analog->num_samples()]);
+       unique_ptr<float[]> data(new float[analog->num_samples()]);
        analog->get_data_as_float(data.get());
 
        if (signalbases_.empty())