@@ -130,12 +130,18 @@ void dlq_init (void)
130
130
#else
131
131
int err ;
132
132
err = pthread_mutex_init (& wake_up_mutex , NULL );
133
+ if (err != 0 ) {
134
+ text_color_set (DW_COLOR_ERROR );
135
+ dw_printf ("dlq_init: pthread_mutex_init err=%d" , err );
136
+ perror ("" );
137
+ exit (EXIT_FAILURE );
138
+ }
133
139
err = pthread_mutex_init (& dlq_mutex , NULL );
134
140
if (err != 0 ) {
135
141
text_color_set (DW_COLOR_ERROR );
136
142
dw_printf ("dlq_init: pthread_mutex_init err=%d" , err );
137
143
perror ("" );
138
- exit (1 );
144
+ exit (EXIT_FAILURE );
139
145
}
140
146
#endif
141
147
@@ -253,6 +259,11 @@ void dlq_rec_frame (int chan, int subchan, int slice, packet_t pp, alevel_t alev
253
259
/* Allocate a new queue item. */
254
260
255
261
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
262
+ if (pnew == NULL ) {
263
+ text_color_set (DW_COLOR_ERROR );
264
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
265
+ exit (EXIT_FAILURE );
266
+ }
256
267
s_new_count ++ ;
257
268
258
269
if (s_new_count > s_delete_count + 50 ) {
@@ -492,6 +503,11 @@ void dlq_connect_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int num
492
503
/* Allocate a new queue item. */
493
504
494
505
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
506
+ if (pnew == NULL ) {
507
+ text_color_set (DW_COLOR_ERROR );
508
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
509
+ exit (EXIT_FAILURE );
510
+ }
495
511
s_new_count ++ ;
496
512
497
513
pnew -> type = DLQ_CONNECT_REQUEST ;
@@ -545,6 +561,11 @@ void dlq_disconnect_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int
545
561
/* Allocate a new queue item. */
546
562
547
563
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
564
+ if (pnew == NULL ) {
565
+ text_color_set (DW_COLOR_ERROR );
566
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
567
+ exit (EXIT_FAILURE );
568
+ }
548
569
s_new_count ++ ;
549
570
550
571
pnew -> type = DLQ_DISCONNECT_REQUEST ;
@@ -603,6 +624,11 @@ void dlq_outstanding_frames_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LE
603
624
/* Allocate a new queue item. */
604
625
605
626
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
627
+ if (pnew == NULL ) {
628
+ text_color_set (DW_COLOR_ERROR );
629
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
630
+ exit (EXIT_FAILURE );
631
+ }
606
632
s_new_count ++ ;
607
633
608
634
pnew -> type = DLQ_OUTSTANDING_FRAMES_REQUEST ;
@@ -670,6 +696,11 @@ void dlq_xmit_data_request (char addrs[AX25_MAX_ADDRS][AX25_MAX_ADDR_LEN], int n
670
696
/* Allocate a new queue item. */
671
697
672
698
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
699
+ if (pnew == NULL ) {
700
+ text_color_set (DW_COLOR_ERROR );
701
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
702
+ exit (EXIT_FAILURE );
703
+ }
673
704
s_new_count ++ ;
674
705
675
706
pnew -> type = DLQ_XMIT_DATA_REQUEST ;
@@ -733,6 +764,11 @@ void dlq_register_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client)
733
764
/* Allocate a new queue item. */
734
765
735
766
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
767
+ if (pnew == NULL ) {
768
+ text_color_set (DW_COLOR_ERROR );
769
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
770
+ exit (EXIT_FAILURE );
771
+ }
736
772
s_new_count ++ ;
737
773
738
774
pnew -> type = DLQ_REGISTER_CALLSIGN ;
@@ -763,6 +799,11 @@ void dlq_unregister_callsign (char addr[AX25_MAX_ADDR_LEN], int chan, int client
763
799
/* Allocate a new queue item. */
764
800
765
801
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
802
+ if (pnew == NULL ) {
803
+ text_color_set (DW_COLOR_ERROR );
804
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
805
+ exit (EXIT_FAILURE );
806
+ }
766
807
s_new_count ++ ;
767
808
768
809
pnew -> type = DLQ_UNREGISTER_CALLSIGN ;
@@ -817,6 +858,11 @@ void dlq_channel_busy (int chan, int activity, int status)
817
858
/* Allocate a new queue item. */
818
859
819
860
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
861
+ if (pnew == NULL ) {
862
+ text_color_set (DW_COLOR_ERROR );
863
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
864
+ exit (EXIT_FAILURE );
865
+ }
820
866
s_new_count ++ ;
821
867
822
868
pnew -> type = DLQ_CHANNEL_BUSY ;
@@ -865,6 +911,11 @@ void dlq_seize_confirm (int chan)
865
911
/* Allocate a new queue item. */
866
912
867
913
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
914
+ if (pnew == NULL ) {
915
+ text_color_set (DW_COLOR_ERROR );
916
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
917
+ exit (EXIT_FAILURE );
918
+ }
868
919
s_new_count ++ ;
869
920
870
921
pnew -> type = DLQ_SEIZE_CONFIRM ;
@@ -910,6 +961,11 @@ void dlq_client_cleanup (int client)
910
961
/* Allocate a new queue item. */
911
962
912
963
pnew = (struct dlq_item_s * ) calloc (sizeof (struct dlq_item_s ), 1 );
964
+ if (pnew == NULL ) {
965
+ text_color_set (DW_COLOR_ERROR );
966
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
967
+ exit (EXIT_FAILURE );
968
+ }
913
969
s_new_count ++ ;
914
970
915
971
// All we care about is the client number.
@@ -1192,6 +1248,11 @@ cdata_t *cdata_new (int pid, char *data, int len)
1192
1248
size = ( len + 127 ) & ~0x7f ;
1193
1249
1194
1250
cdata = malloc ( sizeof (cdata_t ) + size );
1251
+ if (cdata == NULL ) {
1252
+ text_color_set (DW_COLOR_ERROR );
1253
+ dw_printf ("FATAL ERROR: Out of memory.\n" );
1254
+ exit (EXIT_FAILURE );
1255
+ }
1195
1256
1196
1257
cdata -> magic = TXDATA_MAGIC ;
1197
1258
cdata -> next = NULL ;
0 commit comments