You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed this issue when converting the Icecast code. In the file src/net/sock.c the function: int sock_write(sock_t sock, const char *fmt, ...) is incorrectly converted to: int sock_write(int sock, const char *fmt : itype(_Ptr<const char> ) )
I created a small example that highlights the issue:
Original C code var_arg.c:
#include <stdio.h>
#include <stdarg.h>
int fun(int a, ...) {
// define type of variable
va_list L;
int z;
z = 0;
va_start(L, a);
// Loop to adding the int values
for (int i=0; i < a; i++) {
z = z + va_arg(L, int);
}
va_end(L);
return z;
}
int main() {
// Define temporary variables
int x, y, z;
int k;
x = 2;
y = 3;
z = 4;
// calling function
k = fun(3, x, y, z);
// displaying message with result
printf("Total of %d, %d, and %d is %d\n", x, y, z, k);
return 0;
}
checked-c-convert output:
Note: I added #include <stdio_checked.h> and #include <stdchecked.h> before I ran the tool
#include <stdio_checked.h>
#include <stdarg.h>
#include <stdchecked.h>
int fun(int a) {
// define type of variable
va_list L;
int z;
z = 0;
va_start(L, a);
// Loop to adding the int values
for (int i=0; i < a; i++) {
z = z + va_arg(L, int);
}
va_end(L);
return z;
}
int main() {
// Define temporary variables
int x, y, z;
int k;
x = 2;
y = 3;
z = 4;
// calling function
k = fun(3, x, y, z);
// displaying message with result
printf("Total of %d, %d, and %d is %d\n", x, y, z, k);
return 0;
}
The tool deletes the variable argument in fun() causing an error when using va_start()
The text was updated successfully, but these errors were encountered:
…indows. (#626)
* Fix escaping bugs that currently affect the JSON formatting test on
Windows.
Other escaping bugs may remain; #620 is to fix all of them.
Fixes#619.
* Add test of a backslash in a file path on Linux and Mac OS X.
While I'm here, fix a typo in the name of json_formating.c and add `--`
to its `3c` command lines.
I noticed this issue when converting the Icecast code. In the file
src/net/sock.c
the function:int sock_write(sock_t sock, const char *fmt, ...)
is incorrectly converted to:int sock_write(int sock, const char *fmt : itype(_Ptr<const char> ) )
I created a small example that highlights the issue:
Original C code
var_arg.c
:checked-c-convert
output:Note: I added
#include <stdio_checked.h>
and#include <stdchecked.h>
before I ran the toolThe tool deletes the variable argument in
fun()
causing an error when usingva_start()
The text was updated successfully, but these errors were encountered: