@@ -14,41 +14,78 @@ INIT_RUNTIME(2);
1414#define IA2_COMPARTMENT 1
1515#include <ia2_compartment_init.inc>
1616
17- Dav1dContext c IA2_SHARED_DATA ;
18- Dav1dSettings settings IA2_SHARED_DATA ;
19- Dav1dPicture pic IA2_SHARED_DATA ;
20- Dav1dContext c2 IA2_SHARED_DATA ;
21-
2217Test (type_confusion , normal ) {
23- dav1d_open (& c , & settings );
24- dav1d_get_picture (& c , & pic );
25- dav1d_close (& c );
18+ Dav1dContext * c = dav1d_alloc (sizeof (Dav1dContext ));
19+ Dav1dSettings * settings = dav1d_alloc (sizeof (Dav1dSettings ));
20+ Dav1dPicture * pic = dav1d_alloc (sizeof (Dav1dPicture ));
21+
22+ dav1d_open (c , settings );
23+ dav1d_get_picture (c , pic );
24+ dav1d_close (c );
25+
26+ dav1d_free (pic );
27+ dav1d_free (settings );
28+ dav1d_free (c );
2629}
2730
2831Test (type_confusion , uninitialized , .signal = SIGABRT ) {
29- dav1d_open (& c , & settings );
32+ Dav1dContext * c = dav1d_alloc (sizeof (Dav1dContext ));
33+ Dav1dContext * c2 = dav1d_alloc (sizeof (Dav1dContext ));
34+ Dav1dSettings * settings = dav1d_alloc (sizeof (Dav1dSettings ));
35+ Dav1dPicture * pic = dav1d_alloc (sizeof (Dav1dPicture ));
36+
37+ dav1d_open (c , settings );
3038 // Try to use another `Dav1dContext` that hasn't been constructed/opened yet.
31- dav1d_get_picture (& c2 , & pic );
32- dav1d_close (& c );
39+ dav1d_get_picture (c2 , pic ); // Will `SIGABRT`.
40+ dav1d_close (c );
41+
42+ dav1d_free (pic );
43+ dav1d_free (settings );
44+ dav1d_free (c2 );
45+ dav1d_free (c );
3346}
3447
3548Test (type_confusion , wrong_type , .signal = SIGABRT ) {
36- dav1d_open (& c , & settings );
49+ Dav1dContext * c = dav1d_alloc (sizeof (Dav1dContext ));
50+ Dav1dSettings * settings = dav1d_alloc (sizeof (Dav1dSettings ));
51+ Dav1dPicture * pic = dav1d_alloc (sizeof (Dav1dPicture ));
52+
53+ dav1d_open (c , settings );
3754 // Try to use another type (`Dav1dPicture`) instead.
38- dav1d_get_picture ((Dav1dContext * )& pic , & pic );
39- dav1d_close (& c );
55+ dav1d_get_picture ((Dav1dContext * )pic , pic ); // Will `SIGABRT`.
56+ dav1d_close (c );
57+
58+ dav1d_free (pic );
59+ dav1d_free (settings );
60+ dav1d_free (c );
4061}
4162
4263Test (type_confusion , null , .signal = SIGABRT ) {
43- dav1d_open (& c , & settings );
64+ Dav1dContext * c = dav1d_alloc (sizeof (Dav1dContext ));
65+ Dav1dSettings * settings = dav1d_alloc (sizeof (Dav1dSettings ));
66+ Dav1dPicture * pic = dav1d_alloc (sizeof (Dav1dPicture ));
67+
68+ dav1d_open (c , settings );
4469 // Try to `NULL`.
45- dav1d_get_picture (NULL , & pic );
46- dav1d_close (& c );
70+ dav1d_get_picture (NULL , pic ); // Will `SIGABRT`.
71+ dav1d_close (c );
72+
73+ dav1d_free (pic );
74+ dav1d_free (settings );
75+ dav1d_free (c );
4776}
4877
4978Test (type_confusion , use_after_free , .signal = SIGABRT ) {
50- dav1d_open (& c , & settings );
51- dav1d_close (& c );
79+ Dav1dContext * c = dav1d_alloc (sizeof (Dav1dContext ));
80+ Dav1dSettings * settings = dav1d_alloc (sizeof (Dav1dSettings ));
81+ Dav1dPicture * pic = dav1d_alloc (sizeof (Dav1dPicture ));
82+
83+ dav1d_open (c , settings );
84+ dav1d_close (c );
5285 // Try to use an already destructed `Dav1dContext`.
53- dav1d_get_picture (& c , & pic );
86+ dav1d_get_picture (c , pic ); // Will `SIGABRT`.
87+
88+ dav1d_free (pic );
89+ dav1d_free (settings );
90+ dav1d_free (c );
5491}
0 commit comments