Fixed segmentation fault
pull/96/head
Viproz 2018-12-27 16:04:49 +01:00
rodzic 103cf1e2f9
commit 0879ae08f6
2 zmienionych plików z 12 dodań i 9 usunięć

Wyświetl plik

@ -22,16 +22,18 @@ int main(int argc, char** argv) {
++argv;
while (*argv) {
if ((strcmp(*argv, "-h") == 0) || (strcmp(*argv, "--help") == 0)) {
fprintf(stderr, "%s [options] audio.wav\n", fpname);
fprintf(stderr, "%s [options] filename\n", fpname);
fprintf(stderr, " filename needs to be in wav format and blank or - for stdin\n");
fprintf(stderr, " options:\n");
//fprintf(stderr, " -v, --verbose\n");
fprintf(stderr, " -r, --raw\n");
fprintf(stderr, " -c, --color\n");
//fprintf(stderr, " -o, --offset\n");
fprintf(stderr, " -v, --verbose Display even when CRC is wrong\n");
fprintf(stderr, " -R Show result at the end decoded/total\n");
fprintf(stderr, " -b Try alternative method after main method if it failed\n");
fprintf(stderr, " --ch2 Decode the second channel\n");
return 0;
} else if ((strcmp(*argv, "-r") == 0) || (strcmp(*argv, "--raw") == 0)) {
decoder.setRaw(true);
} else if (strcmp(*argv, "-v") == 0) {
} else if (strcmp(*argv, "-v") == 0 || strcmp(*argv, "--verbose") == 0) {
decoder.setVerboseLevel(1);
} else if (strcmp(*argv, "-b") == 0) {
decoder.setTryMethodSign(true);

Wyświetl plik

@ -21,12 +21,13 @@ M10Decoder::~M10Decoder() {
delete m10GTop;
delete m10Ptu;
delete frameSamples;
if (samplesPerBit != 0)
delete frameSamples;
}
int M10Decoder::startDecode(std::string fname) {
filename = fname;
if (filename == "")
if (filename == "" || filename == "-")
fp = stdin;
else
fp = fopen(filename.c_str(), "rb");
@ -155,7 +156,7 @@ double M10Decoder::findFrameStart() {
int tmpIndex = 0;
valIndex--;
valIndex %= smallBufLen;
if(j - (int) pos > smallBufLen) // If absurdly long way back
if (j - (int) pos > smallBufLen) // If absurdly long way back
continue;
// Store the previous values in the buffer
for (curIndex = 0; curIndex < (j - (int) pos); ++curIndex) {