Browse Source

Check return value of asprintf() because it could fail

Georgi Chorbadzhiyski 7 years ago
parent
commit
d3b56ef510
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      misc.c

+ 4
- 4
misc.c View File

@@ -185,14 +185,14 @@ char *h222_stream_id_desc(uint8_t stream_id) {
185 185
 	}
186 186
 	if (stream_id >= 0xc0 && stream_id <= 0xdf) {
187 187
 		stream_number = stream_id & 0x1f;
188
-		asprintf(&text, "Audio stream %d", stream_number);
188
+		if (asprintf(&text, "Audio stream %d", stream_number) < 0) return NULL;
189 189
 	} else if (stream_id >= 0xe0 && stream_id <= 0xef) {
190 190
 		stream_number = stream_id & 0x0f;
191
-		asprintf(&text, "Video stream %d", stream_number);
191
+		if (asprintf(&text, "Video stream %d", stream_number) < 0) return NULL;
192 192
 	} else if (stream_id >= 0xfc && stream_id <= 0xfe) {
193
-		asprintf(&text, "Reserved data stream");
193
+		if (asprintf(&text, "Reserved data stream") < 0) return NULL;
194 194
 	} else {
195
-		asprintf(&text, "Unrecognised stream id 0x%02x", stream_id);
195
+		if (asprintf(&text, "Unrecognised stream id 0x%02x", stream_id) < 0) return NULL;
196 196
 	}
197 197
 	return text;
198 198
 }

Loading…
Cancel
Save