Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
hiredis
Commits
27c96dde
Commit
27c96dde
authored
Jul 09, 2011
by
Pieter Noordhuis
Browse files
Use correct type when calling va_arg in formatter
parent
4ac55be9
Changes
1
Show whitespace changes
Inline
Side-by-side
hiredis.c
View file @
27c96dde
...
@@ -770,33 +770,81 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) {
...
@@ -770,33 +770,81 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) {
while
(
*
_p
!=
'\0'
&&
isdigit
(
*
_p
))
_p
++
;
while
(
*
_p
!=
'\0'
&&
isdigit
(
*
_p
))
_p
++
;
}
}
/* Modifiers */
/* Copy va_list before consuming with va_arg */
if
(
*
_p
!=
'\0'
)
{
va_copy
(
_cpy
,
ap
);
if
(
*
_p
==
'h'
||
*
_p
==
'l'
)
{
/* Allow a single repetition for these modifiers */
/* Integer conversion (without modifiers) */
if
(
_p
[
0
]
==
_p
[
1
])
_p
++
;
if
(
strchr
(
"diouxX"
,
*
_p
)
!=
NULL
)
{
_p
++
;
va_arg
(
ap
,
int
);
goto
fmt_valid
;
}
/* Double conversion (without modifiers) */
if
(
strchr
(
"eEfFgGaA"
,
*
_p
)
!=
NULL
)
{
va_arg
(
ap
,
double
);
goto
fmt_valid
;
}
/* Size: char */
if
(
_p
[
0
]
==
'h'
&&
_p
[
1
]
==
'h'
)
{
_p
+=
2
;
if
(
*
_p
!=
'\0'
&&
strchr
(
"diouxX"
,
*
_p
)
!=
NULL
)
{
va_arg
(
ap
,
int
);
/* char gets promoted to int */
goto
fmt_valid
;
}
goto
fmt_invalid
;
}
/* Size: short */
if
(
_p
[
0
]
==
'h'
)
{
_p
+=
1
;
if
(
*
_p
!=
'\0'
&&
strchr
(
"diouxX"
,
*
_p
)
!=
NULL
)
{
va_arg
(
ap
,
int
);
/* short gets promoted to int */
goto
fmt_valid
;
}
goto
fmt_invalid
;
}
/* Size: long long */
if
(
_p
[
0
]
==
'l'
&&
_p
[
1
]
==
'l'
)
{
_p
+=
2
;
if
(
*
_p
!=
'\0'
&&
strchr
(
"diouxX"
,
*
_p
)
!=
NULL
)
{
va_arg
(
ap
,
long
long
);
goto
fmt_valid
;
}
goto
fmt_invalid
;
}
}
/* Size: long */
if
(
_p
[
0
]
==
'l'
)
{
_p
+=
1
;
if
(
*
_p
!=
'\0'
&&
strchr
(
"diouxX"
,
*
_p
)
!=
NULL
)
{
va_arg
(
ap
,
long
);
goto
fmt_valid
;
}
goto
fmt_invalid
;
}
}
/* Conversion specifier */
fmt_invalid:
if
(
*
_p
!=
'\0'
&&
strchr
(
"diouxXeEfFgGaA"
,
*
_p
)
!=
NULL
)
{
/* Consume and discard vararg */
va_arg
(
ap
,
void
);
va_end
(
_cpy
);
break
;
fmt_valid:
_l
=
(
_p
+
1
)
-
c
;
_l
=
(
_p
+
1
)
-
c
;
if
(
_l
<
sizeof
(
_format
)
-
2
)
{
if
(
_l
<
sizeof
(
_format
)
-
2
)
{
memcpy
(
_format
,
c
,
_l
);
memcpy
(
_format
,
c
,
_l
);
_format
[
_l
]
=
'\0'
;
_format
[
_l
]
=
'\0'
;
va_copy
(
_cpy
,
ap
);
newarg
=
sdscatvprintf
(
curarg
,
_format
,
_cpy
);
newarg
=
sdscatvprintf
(
curarg
,
_format
,
_cpy
);
va_end
(
_cpy
);
/* Update current position (note: outer blocks
/* Update current position (note: outer blocks
* increment c twice so compensate here) */
* increment c twice so compensate here) */
c
=
_p
-
1
;
c
=
_p
-
1
;
}
}
}
/* Consume and discard vararg */
va_end
(
_cpy
);
va_arg
(
ap
,
void
)
;
break
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment