Mercurial > libavcodec.hg
comparison eval.c @ 1815:2152760d08ad libavcodec
avoid negative array indices
author | alex |
---|---|
date | Wed, 18 Feb 2004 12:49:30 +0000 |
parents | 932d306bf1dc |
children | 0934621b6453 |
comparison
equal
deleted
inserted
replaced
1814:4804dddf2d0e | 1815:2152760d08ad |
---|---|
113 return; | 113 return; |
114 } | 114 } |
115 p->s++; // "(" | 115 p->s++; // "(" |
116 evalExpression(p); | 116 evalExpression(p); |
117 d= pop(p); | 117 d= pop(p); |
118 p->s++; // ")" or "," | 118 if(p->s[0]== ','){ |
119 if(p->s[-1]== ','){ | 119 p->s++; // "," |
120 evalExpression(p); | 120 evalExpression(p); |
121 d2= pop(p); | 121 d2= pop(p); |
122 p->s++; // ")" | 122 } |
123 } | 123 if(p->s[0] != ')'){ |
124 av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", next); | |
125 return; | |
126 } | |
127 p->s++; // ")" | |
124 | 128 |
125 if( strmatch(next, "sinh" ) ) d= sinh(d); | 129 if( strmatch(next, "sinh" ) ) d= sinh(d); |
126 else if( strmatch(next, "cosh" ) ) d= cosh(d); | 130 else if( strmatch(next, "cosh" ) ) d= cosh(d); |
127 else if( strmatch(next, "tanh" ) ) d= tanh(d); | 131 else if( strmatch(next, "tanh" ) ) d= tanh(d); |
128 else if( strmatch(next, "sin" ) ) d= sin(d); | 132 else if( strmatch(next, "sin" ) ) d= sin(d); |
134 else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI); | 138 else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI); |
135 else if( strmatch(next, "abs" ) ) d= fabs(d); | 139 else if( strmatch(next, "abs" ) ) d= fabs(d); |
136 else if( strmatch(next, "max" ) ) d= d > d2 ? d : d2; | 140 else if( strmatch(next, "max" ) ) d= d > d2 ? d : d2; |
137 else if( strmatch(next, "min" ) ) d= d < d2 ? d : d2; | 141 else if( strmatch(next, "min" ) ) d= d < d2 ? d : d2; |
138 else if( strmatch(next, "gt" ) ) d= d > d2 ? 1.0 : 0.0; | 142 else if( strmatch(next, "gt" ) ) d= d > d2 ? 1.0 : 0.0; |
143 else if( strmatch(next, "gte" ) ) d= d >= d2 ? 1.0 : 0.0; | |
139 else if( strmatch(next, "lt" ) ) d= d > d2 ? 0.0 : 1.0; | 144 else if( strmatch(next, "lt" ) ) d= d > d2 ? 0.0 : 1.0; |
145 else if( strmatch(next, "lte" ) ) d= d >= d2 ? 0.0 : 1.0; | |
140 else if( strmatch(next, "eq" ) ) d= d == d2 ? 1.0 : 0.0; | 146 else if( strmatch(next, "eq" ) ) d= d == d2 ? 1.0 : 0.0; |
141 // else if( strmatch(next, "l1" ) ) d= 1 + d2*(d - 1); | 147 // else if( strmatch(next, "l1" ) ) d= 1 + d2*(d - 1); |
142 // else if( strmatch(next, "sq01" ) ) d= (d >= 0.0 && d <=1.0) ? 1.0 : 0.0; | 148 // else if( strmatch(next, "sq01" ) ) d= (d >= 0.0 && d <=1.0) ? 1.0 : 0.0; |
143 else{ | 149 else{ |
144 int error=1; | 150 int error=1; |
162 av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next); | 168 av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next); |
163 return; | 169 return; |
164 } | 170 } |
165 } | 171 } |
166 | 172 |
167 if(p->s[-1]!= ')'){ | |
168 av_log(NULL, AV_LOG_ERROR, "Parser: missing ) in \"%s\"\n", next); | |
169 return; | |
170 } | |
171 push(p, d); | 173 push(p, d); |
172 } | 174 } |
173 | 175 |
174 static void evalPow(Parser *p){ | 176 static void evalPow(Parser *p){ |
175 int neg= 0; | 177 int neg= 0; |