cake
cake copied to clipboard
missing lifetime checks
#include <ownership.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct X {
char * owner s;
};
void destroy(struct X * obj_owner p) {free(p->s);}
void f1(){
struct X x = {0};
struct X* p = &x;
x.s = strdup("a");
destroy(&x);
printf("%s", p->s);
}
void f2(){
struct X* p = 0;
{
struct X x = {0};
p = &x;
x.s = strdup("a");
destroy(&x);
}
printf("%s", p->s);
}
int main(){
}
unit test created