Fix for yajl#188 potential UB

Apparently it is UB to use an enum in va_start()
This commit is contained in:
Andrew Johnson
2020-07-06 21:48:10 -05:00
parent e542a22631
commit d381a936b5
4 changed files with 8 additions and 6 deletions

View File

@@ -82,11 +82,12 @@ yajl_alloc(const yajl_callbacks * callbacks,
}
int
yajl_config(yajl_handle h, yajl_option opt, ...)
yajl_config(yajl_handle h, int option, ...)
{
yajl_option opt = option; /* UB to use an enum in va_start */
int rv = 1;
va_list ap;
va_start(ap, opt);
va_start(ap, option);
switch(opt) {
case yajl_allow_comments:

View File

@@ -48,11 +48,12 @@ struct yajl_gen_t
};
int
yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...)
yajl_gen_config(yajl_gen g, int option, ...)
{
yajl_gen_option opt = option; /* UB to use an enum in va_start */
int rv = 1;
va_list ap;
va_start(ap, opt);
va_start(ap, option);
switch(opt) {
case yajl_gen_beautify:

View File

@@ -105,7 +105,7 @@ extern "C" {
* allocation (via yajl_alloc())
* \returns zero in case of errors, non-zero otherwise
*/
YAJL_API int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...);
YAJL_API int yajl_gen_config(yajl_gen hand, int option, ...);
/** Allocate a generator handle
* \param allocFuncs An optional pointer to a structure which allows

View File

@@ -162,7 +162,7 @@ extern "C" {
* allocation (via yajl_alloc())
* \returns zero in case of errors, non-zero otherwise
*/
YAJL_API int yajl_config(yajl_handle h, yajl_option opt, ...);
YAJL_API int yajl_config(yajl_handle h, int option, ...);
/** Free a parser handle */
YAJL_API void yajl_free(yajl_handle handle);