Skip to content

Commit 7c7d514

Browse files
committed
Added callback null check for each template class
per @c1728p9 #131
1 parent 9615763 commit 7c7d514

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

hal/api/Callback.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class Callback<R(A0, A1, A2, A3, A4)> {
106106
/** Call the attached function
107107
*/
108108
R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
109+
if (!_thunk) {
110+
return (R)0;
111+
}
109112
return _thunk(_obj, &_func, a0, a1, a2, a3, a4);
110113
}
111114

@@ -244,6 +247,9 @@ class Callback<R(A0, A1, A2, A3)> {
244247
/** Call the attached function
245248
*/
246249
R call(A0 a0, A1 a1, A2 a2, A3 a3) {
250+
if (!_thunk) {
251+
return (R)0;
252+
}
247253
return _thunk(_obj, &_func, a0, a1, a2, a3);
248254
}
249255

@@ -382,6 +388,9 @@ class Callback<R(A0, A1, A2)> {
382388
/** Call the attached function
383389
*/
384390
R call(A0 a0, A1 a1, A2 a2) {
391+
if (!_thunk) {
392+
return (R)0;
393+
}
385394
return _thunk(_obj, &_func, a0, a1, a2);
386395
}
387396

@@ -520,6 +529,9 @@ class Callback<R(A0, A1)> {
520529
/** Call the attached function
521530
*/
522531
R call(A0 a0, A1 a1) {
532+
if (!_thunk) {
533+
return (R)0;
534+
}
523535
return _thunk(_obj, &_func, a0, a1);
524536
}
525537

@@ -658,6 +670,9 @@ class Callback<R(A0)> {
658670
/** Call the attached function
659671
*/
660672
R call(A0 a0) {
673+
if (!_thunk) {
674+
return (R)0;
675+
}
661676
return _thunk(_obj, &_func, a0);
662677
}
663678

@@ -796,7 +811,7 @@ class Callback<R()> {
796811
/** Call the attached function
797812
*/
798813
R call() {
799-
if (NULL == _thunk) {
814+
if (!_thunk) {
800815
return (R)0;
801816
}
802817
return _thunk(_obj, &_func);

0 commit comments

Comments
 (0)