Bug 1247864 - delete[] on anything allocated with new[]. r=cpearce
authorradu stoica <radu.stoica@softvision.ro>
Fri, 12 Feb 2016 01:06:00 -0500
changeset 340563 ce674f4e79df6250d3f544187be6d2adae35d4ea
parent 340562 7f8a1c681597d1f1cfcc33fe47dcf59aff04b924
child 340564 936703b9e4cd5c8aafd66767af2953415ddf498a
push id13010
push userrjesup@wgate.com
push dateTue, 15 Mar 2016 17:32:10 +0000
reviewerscpearce
bugs1247864
milestone48.0a1
Bug 1247864 - delete[] on anything allocated with new[]. r=cpearce
dom/media/compiledtest/TestAudioPacketizer.cpp
--- a/dom/media/compiledtest/TestAudioPacketizer.cpp
+++ b/dom/media/compiledtest/TestAudioPacketizer.cpp
@@ -65,32 +65,32 @@ double sine(uint32_t aPhase) {
 int main() {
   for (int16_t channels = 1; channels < 2; channels++) {
     // Test that the packetizer returns zero on underrun
     {
       AudioPacketizer<int16_t, int16_t> ap(441, channels);
       for (int16_t i = 0; i < 10; i++) {
         int16_t* out = ap.Output();
         Zero(out, 441);
-        delete out;
+        delete[] out;
       }
     }
     // Simple test, with input/output buffer size aligned on the packet size,
     // alternating Input and Output calls.
     {
       AudioPacketizer<int16_t, int16_t> ap(441, channels);
       int16_t seqEnd = 0;
       for (int16_t i = 0; i < 10; i++) {
         AutoBuffer<int16_t> b(441 * channels);
         int16_t prevEnd = seqEnd;
         seqEnd = Sequence(b.Get(), channels * 441, prevEnd);
         ap.Input(b.Get(), 441);
         int16_t* out = ap.Output();
         IsSequence(out, 441 * channels, prevEnd);
-        delete out;
+        delete[] out;
       }
     }
     // Simple test, with input/output buffer size aligned on the packet size,
     // alternating two Input and Output calls.
     {
       AudioPacketizer<int16_t, int16_t> ap(441, channels);
       int16_t seqEnd = 0;
       for (int16_t i = 0; i < 10; i++) {
@@ -101,18 +101,18 @@ int main() {
         int16_t prevEnd1 = seqEnd;
         seqEnd = Sequence(b1.Get(), 441 * channels, seqEnd);
         ap.Input(b.Get(), 441);
         ap.Input(b1.Get(), 441);
         int16_t* out = ap.Output();
         int16_t* out2 = ap.Output();
         IsSequence(out, 441 * channels, prevEnd0);
         IsSequence(out2, 441 * channels, prevEnd1);
-        delete out;
-        delete out2;
+        delete[] out;
+        delete[] out2;
       }
     }
     // Input/output buffer size not aligned on the packet size,
     // alternating two Input and Output calls.
     {
       AudioPacketizer<int16_t, int16_t> ap(441, channels);
       int16_t prevEnd = 0;
       int16_t prevSeq = 0;
@@ -124,18 +124,18 @@ int main() {
         ap.Input(b.Get(), 480);
         ap.Input(b1.Get(), 480);
         int16_t* out = ap.Output();
         int16_t* out2 = ap.Output();
         IsSequence(out, 441 * channels, prevEnd);
         prevEnd += 441 * channels;
         IsSequence(out2, 441 * channels, prevEnd);
         prevEnd += 441 * channels;
-        delete out;
-        delete out2;
+        delete[] out;
+        delete[] out2;
       }
       printf("Available: %d\n", ap.PacketsAvailable());
     }
 
     // "Real-life" test case: streaming a sine wave through a packetizer, and
     // checking that we have the right output.
     // 128 is, for example, the size of a Web Audio API block, and 441 is the
     // size of a webrtc.org packet when the sample rate is 44100 (10ms)