videolabs / libspatialaudio

Ambisonic encoding / decoding and binauralization library in C++
Other
192 stars 37 forks source link

CAmbisonicBinauralizer::Process() Segmentation fault (core dumped) #31

Open Tangduf opened 3 years ago

Tangduf commented 3 years ago

i want to use CAmbisonicBinauralizer::Process(), but when run code to "memcpy(ppfDst[0], m_pfScratchBufferA.data(), nSamples * sizeof(float));" it report error "Segmentation fault (core dumped)" . i create a new file ,file name is test.c ,the code :

#include<stdio.h>
#include <stdlib.h>
#include <cstring>

int main()
{
    float **result = (float **)malloc(sizeof(float)*20);
    float test[5] = {0};
    memcpy(result[0],test, 2*sizeof(float));
    free(result);
    return 1;
}

when i run this code by comand : g++ test.c -std=c++11 or c++03 or c++17 or c++20,it also report Segmentation fault. so we should not use "memcpy(ppfDst[0], m_pfScratchBufferA.data(), nSamples * sizeof(float));" when ppfDst type is float **,is it right?