forked from tTh/FloatImg
fix a segfault in parse_filter_chain
This commit is contained in:
parent
22ef7c084e
commit
6bd95089f9
@ -5,6 +5,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <alloca.h>
|
||||||
|
|
||||||
#include "../floatimg.h"
|
#include "../floatimg.h"
|
||||||
#include "crapulator.h"
|
#include "crapulator.h"
|
||||||
@ -165,7 +166,7 @@ return -1;
|
|||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
int parse_filter_chain(int numid, char *argument)
|
int parse_filter_chain(int numid, char *argument)
|
||||||
{
|
{
|
||||||
char *cptr;
|
char *cptr, *tmparg;
|
||||||
int value, foo;
|
int value, foo;
|
||||||
|
|
||||||
if (numid < 0 || numid > NUMBER_OF_STACK) {
|
if (numid < 0 || numid > NUMBER_OF_STACK) {
|
||||||
@ -181,11 +182,19 @@ if (foo) {
|
|||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* BUG ?
|
||||||
|
If the 'argument' string is coming from a default value (as defined
|
||||||
|
here in main), strtok make a nice segfault. so I make a copy of that
|
||||||
|
string...
|
||||||
|
*/
|
||||||
|
tmparg = alloca(strlen(argument) + 1);
|
||||||
|
strcpy(tmparg, argument);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
cptr = strtok(argument, ":");
|
cptr = strtok(tmparg, ":");
|
||||||
// fprintf(stderr, "cptr %p\n", cptr);
|
// fprintf(stderr, "cptr %p\n", cptr);
|
||||||
if (NULL==cptr) break;
|
if (NULL==cptr) break;
|
||||||
argument = NULL;
|
tmparg = NULL; /* for the next pass of strtok */
|
||||||
// fprintf(stderr, " parsing '%s'\n", cptr);
|
// fprintf(stderr, " parsing '%s'\n", cptr);
|
||||||
if (1 == sscanf(cptr, "%d", &value)) {
|
if (1 == sscanf(cptr, "%d", &value)) {
|
||||||
foo = filterstack_add(numid, value, 1, 1.0);
|
foo = filterstack_add(numid, value, 1, 1.0);
|
||||||
|
Loading…
Reference in New Issue
Block a user