History

fftools/textformat: Apply quality improvements

Perform multiple improvements to increase code robustness. In particular: - favor unsigned counters for loops - add missing checks - avoid possible leaks - move variable declarations to inner scopes when feasible - provide explicit type-casting when needed

softworkz committed 1 year ago

Commit 5f90eea1 parent 8f42d907 files · +82 −45Browse files

Unified · Split

7 files
  1. fftools/textformat/avtextformat.c +55 −27
  2. fftools/textformat/avtextformat.h +2 −4
  3. fftools/textformat/tf_default.c +6 −2
  4. fftools/textformat/tf_ini.c +1 −1
  5. fftools/textformat/tf_json.c +10 −7
  6. fftools/textformat/tf_xml.c +0 −3
  7. fftools/textformat/tw_avio.c +8 −1
fftools/textformat/avtextformat.c+55−27
@@ -93,9 +93,8 @@ static const AVClass textcontext_class = { · 92 unmodified lines
93 93
94static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)94static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
95{95{
96 int i;
97 av_bprintf(bp, "0X");96 av_bprintf(bp, "0X");
98 for (i = 0; i < ubuf_size; i++)97 for (unsigned i = 0; i < ubuf_size; i++)
99 av_bprintf(bp, "%02X", ubuf[i]);98 av_bprintf(bp, "%02X", ubuf[i]);
100}99}
101 100
@@ -137,6 +136,8 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form · 35 unmodified lines
137 AVTextFormatContext *tctx;136 AVTextFormatContext *tctx;
138 int i, ret = 0;137 int i, ret = 0;
139 138
139 av_assert0(ptctx && formatter);
140
140 if (!(tctx = av_mallocz(sizeof(AVTextFormatContext)))) {141 if (!(tctx = av_mallocz(sizeof(AVTextFormatContext)))) {
141 ret = AVERROR(ENOMEM);142 ret = AVERROR(ENOMEM);
142 goto fail;143 goto fail;
@@ -215,8 +216,8 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form · 72 unmodified lines
215 216
216 /* validate replace string */217 /* validate replace string */
217 {218 {
218 const uint8_t *p = tctx->string_validation_replacement;219 const uint8_t *p = (uint8_t *)tctx->string_validation_replacement;
219 const uint8_t *endp = p + strlen(p);220 const uint8_t *endp = p + strlen((const char *)p);
220 while (*p) {221 while (*p) {
221 const uint8_t *p0 = p;222 const uint8_t *p0 = p;
222 int32_t code;223 int32_t code;
@@ -229,6 +230,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form · 6 unmodified lines
229 "Invalid UTF8 sequence %s found in string validation replace '%s'\n",230 "Invalid UTF8 sequence %s found in string validation replace '%s'\n",
230 bp.str, tctx->string_validation_replacement);231 bp.str, tctx->string_validation_replacement);
231 return ret;232 return ret;
233 goto fail;
232 }234 }
233 }235 }
234 }236 }
@@ -256,6 +258,11 @@ static const char unit_bit_per_second_str[] = "bit/s"; · 21 unmodified lines
256 258
257void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id)259void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id)
258{260{
261 if (section_id < 0 || section_id >= tctx->nb_sections) {
262 av_log(tctx, AV_LOG_ERROR, "Invalid section_id for section_header: %d\n", section_id);
263 return;
264 }
265
259 tctx->level++;266 tctx->level++;
260 av_assert0(tctx->level < SECTION_MAX_NB_LEVELS);267 av_assert0(tctx->level < SECTION_MAX_NB_LEVELS);
261 268
@@ -269,6 +276,11 @@ void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, in · 7 unmodified lines
269 276
270void avtext_print_section_footer(AVTextFormatContext *tctx)277void avtext_print_section_footer(AVTextFormatContext *tctx)
271{278{
279 if (tctx->level < 0 || tctx->level >= SECTION_MAX_NB_LEVELS) {
280 av_log(tctx, AV_LOG_ERROR, "Invalid level for section_footer: %d\n", tctx->level);
281 return;
282 }
283
272 int section_id = tctx->section[tctx->level]->id;284 int section_id = tctx->section[tctx->level]->id;
273 int parent_section_id = tctx->level ?285 int parent_section_id = tctx->level ?
274 tctx->section[tctx->level - 1]->id : SECTION_ID_NONE;286 tctx->section[tctx->level - 1]->id : SECTION_ID_NONE;
@@ -285,7 +297,11 @@ void avtext_print_section_footer(AVTextFormatContext *tctx) · 10 unmodified lines
285 297
286void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val)298void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val)
287{299{
288 const struct AVTextFormatSection *section = tctx->section[tctx->level];300 const AVTextFormatSection *section;
301
302 av_assert0(key && tctx->level >= 0 && tctx->level < SECTION_MAX_NB_LEVELS);
303
304 section = tctx->section[tctx->level];
289 305
290 if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {306 if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {
291 tctx->formatter->print_integer(tctx, key, val);307 tctx->formatter->print_integer(tctx, key, val);
@@ -354,17 +370,18 @@ struct unit_value { · 62 unmodified lines
354 const char *unit;370 const char *unit;
355};371};
356 372
357static char *value_string(AVTextFormatContext *tctx, char *buf, int buf_size, struct unit_value uv)373static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_size, struct unit_value uv)
358{374{
359 double vald;375 double vald;
360 int64_t vali;376 int64_t vali = 0;
361 int show_float = 0;377 int show_float = 0;
362 378
363 if (uv.unit == unit_second_str) {379 if (uv.unit == unit_second_str) {
364 vald = uv.val.d;380 vald = uv.val.d;
365 show_float = 1;381 show_float = 1;
366 } else {382 } else {
367 vald = vali = uv.val.i;383 vald = (double)uv.val.i;
384 vali = uv.val.i;
368 }385 }
369 386
370 if (uv.unit == unit_second_str && tctx->use_value_sexagesimal_format) {387 if (uv.unit == unit_second_str && tctx->use_value_sexagesimal_format) {
@@ -383,17 +400,17 @@ static char *value_string(AVTextFormatContext *tctx, char *buf, int buf_size, st · 12 unmodified lines
383 int64_t index;400 int64_t index;
384 401
385 if (uv.unit == unit_byte_str && tctx->use_byte_value_binary_prefix) {402 if (uv.unit == unit_byte_str && tctx->use_byte_value_binary_prefix) {
386 index = (int64_t) (log2(vald)) / 10;403 index = (int64_t)(log2(vald) / 10);
387 index = av_clip(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);404 index = av_clip64(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);
388 vald /= si_prefixes[index].bin_val;405 vald /= si_prefixes[index].bin_val;
389 prefix_string = si_prefixes[index].bin_str;406 prefix_string = si_prefixes[index].bin_str;
390 } else {407 } else {
391 index = (int64_t) (log10(vald)) / 3;408 index = (int64_t)(log10(vald) / 3);
392 index = av_clip(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);409 index = av_clip64(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);
393 vald /= si_prefixes[index].dec_val;410 vald /= si_prefixes[index].dec_val;
394 prefix_string = si_prefixes[index].dec_str;411 prefix_string = si_prefixes[index].dec_str;
395 }412 }
396 vali = vald;413 vali = (int64_t)vald;
397 }414 }
398 415
399 if (show_float || (tctx->use_value_prefix && vald != (int64_t)vald))416 if (show_float || (tctx->use_value_prefix && vald != (int64_t)vald))
@@ -421,9 +438,13 @@ void avtext_print_unit_int(AVTextFormatContext *tctx, const char *key, int value · 21 unmodified lines
421 438
422int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags)439int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags)
423{440{
424 const struct AVTextFormatSection *section = tctx->section[tctx->level];441 const AVTextFormatSection *section;
425 int ret = 0;442 int ret = 0;
426 443
444 av_assert0(key && val && tctx->level >= 0 && tctx->level < SECTION_MAX_NB_LEVELS);
445
446 section = tctx->section[tctx->level];
447
427 if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER ||448 if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER ||
428 (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO449 (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
429 && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)450 && (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
@@ -465,12 +486,11 @@ void avtext_print_rational(AVTextFormatContext *tctx, const char *key, AVRationa · 35 unmodified lines
465void avtext_print_time(AVTextFormatContext *tctx, const char *key,486void avtext_print_time(AVTextFormatContext *tctx, const char *key,
466 int64_t ts, const AVRational *time_base, int is_duration)487 int64_t ts, const AVRational *time_base, int is_duration)
467{488{
468 char buf[128];
469
470 if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {489 if ((!is_duration && ts == AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
471 avtext_print_string(tctx, key, "N/A", AV_TEXTFORMAT_PRINT_STRING_OPTIONAL);490 avtext_print_string(tctx, key, "N/A", AV_TEXTFORMAT_PRINT_STRING_OPTIONAL);
472 } else {491 } else {
473 double d = ts * av_q2d(*time_base);492 char buf[128];
493 double d = av_q2d(*time_base) * ts;
474 struct unit_value uv;494 struct unit_value uv;
475 uv.val.d = d;495 uv.val.d = d;
476 uv.unit = unit_second_str;496 uv.unit = unit_second_str;
@@ -491,7 +511,8 @@ void avtext_print_data(AVTextFormatContext *tctx, const char *name, · 14 unmodified lines
491 const uint8_t *data, int size)511 const uint8_t *data, int size)
492{512{
493 AVBPrint bp;513 AVBPrint bp;
494 int offset = 0, l, i;514 unsigned offset = 0;
515 int l, i;
495 516
496 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);517 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
497 av_bprintf(&bp, "\n");518 av_bprintf(&bp, "\n");
@@ -518,25 +539,29 @@ void avtext_print_data(AVTextFormatContext *tctx, const char *name, · 20 unmodified lines
518void avtext_print_data_hash(AVTextFormatContext *tctx, const char *name,539void avtext_print_data_hash(AVTextFormatContext *tctx, const char *name,
519 const uint8_t *data, int size)540 const uint8_t *data, int size)
520{541{
521 char *p, buf[AV_HASH_MAX_SIZE * 2 + 64] = { 0 };542 char buf[AV_HASH_MAX_SIZE * 2 + 64] = { 0 };
543 int len;
522 544
523 if (!tctx->hash)545 if (!tctx->hash)
524 return;546 return;
525 547
526 av_hash_init(tctx->hash);548 av_hash_init(tctx->hash);
527 av_hash_update(tctx->hash, data, size);549 av_hash_update(tctx->hash, data, size);
528 snprintf(buf, sizeof(buf), "%s:", av_hash_get_name(tctx->hash));550 len = snprintf(buf, sizeof(buf), "%s:", av_hash_get_name(tctx->hash));
529 p = buf + strlen(buf);551 av_hash_final_hex(tctx->hash, (uint8_t *)&buf[len], (int)sizeof(buf) - len);
530 av_hash_final_hex(tctx->hash, p, buf + sizeof(buf) - p);
531 avtext_print_string(tctx, name, buf, 0);552 avtext_print_string(tctx, name, buf, 0);
532}553}
533 554
534void avtext_print_integers(AVTextFormatContext *tctx, const char *name,555void avtext_print_integers(AVTextFormatContext *tctx, const char *name,
535 uint8_t *data, int size, const char *format,556 uint8_t *data, int size, const char *format,
536 int columns, int bytes, int offset_add)557 int columns, int bytes, int offset_add)
537{558{
538 AVBPrint bp;559 AVBPrint bp;
539 int offset = 0, l, i;560 unsigned offset = 0;
561 int l, i;
562
563 if (!name || !data || !format || columns <= 0 || bytes <= 0)
564 return;
540 565
541 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);566 av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
542 av_bprintf(&bp, "\n");567 av_bprintf(&bp, "\n");
@@ -602,12 +627,15 @@ int avtextwriter_context_open(AVTextWriterContext **pwctx, const AVTextWriter *w · 59 unmodified lines
602 AVTextWriterContext *wctx;627 AVTextWriterContext *wctx;
603 int ret = 0;628 int ret = 0;
604 629
605 if (!(wctx = av_mallocz(sizeof(AVTextWriterContext)))) {630 if (!pwctx || !writer)
631 return AVERROR(EINVAL);
632
633 if (!((wctx = av_mallocz(sizeof(AVTextWriterContext))))) {
606 ret = AVERROR(ENOMEM);634 ret = AVERROR(ENOMEM);
607 goto fail;635 goto fail;
608 }636 }
609 637
610 if (!(wctx->priv = av_mallocz(writer->priv_size))) {638 if (writer->priv_size && !((wctx->priv = av_mallocz(writer->priv_size)))) {
611 ret = AVERROR(ENOMEM);639 ret = AVERROR(ENOMEM);
612 goto fail;640 goto fail;
613 }641 }
fftools/textformat/avtextformat.h+2−4
@@ -21,9 +21,7 @@ · 20 unmodified lines
21#ifndef FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H21#ifndef FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H
22#define FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H22#define FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H
23 23
24#include <stddef.h>
25#include <stdint.h>24#include <stdint.h>
26#include "libavutil/attributes.h"
27#include "libavutil/dict.h"25#include "libavutil/dict.h"
28#include "libavformat/avio.h"26#include "libavformat/avio.h"
29#include "libavutil/bprint.h"27#include "libavutil/bprint.h"
@@ -103,7 +101,7 @@ struct AVTextFormatContext { · 73 unmodified lines
103 unsigned int nb_item_type[SECTION_MAX_NB_LEVELS][SECTION_MAX_NB_SECTIONS];101 unsigned int nb_item_type[SECTION_MAX_NB_LEVELS][SECTION_MAX_NB_SECTIONS];
104 102
105 /** section per each level */103 /** section per each level */
106 const struct AVTextFormatSection *section[SECTION_MAX_NB_LEVELS];104 const AVTextFormatSection *section[SECTION_MAX_NB_LEVELS];
107 AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer dedicated to each section,105 AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer dedicated to each section,
108 /// used by various formatters106 /// used by various formatters
109 107
@@ -124,7 +122,7 @@ struct AVTextFormatContext { · 14 unmodified lines
124#define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2122#define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2
125 123
126int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args,124int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args,
127 const struct AVTextFormatSection *sections, int nb_sections,125 const AVTextFormatSection *sections, int nb_sections,
128 int show_value_unit,126 int show_value_unit,
129 int use_value_prefix,127 int use_value_prefix,
130 int use_byte_value_binary_prefix,128 int use_byte_value_binary_prefix,
fftools/textformat/tf_default.c+6−2
@@ -68,9 +68,10 @@ DEFINE_FORMATTER_CLASS(default); · 67 unmodified lines
68/* lame uppercasing routine, assumes the string is lower case ASCII */68/* lame uppercasing routine, assumes the string is lower case ASCII */
69static inline char *upcase_string(char *dst, size_t dst_size, const char *src)69static inline char *upcase_string(char *dst, size_t dst_size, const char *src)
70{70{
71 int i;71 unsigned i;
72
72 for (i = 0; src[i] && i < dst_size - 1; i++)73 for (i = 0; src[i] && i < dst_size - 1; i++)
73 dst[i] = av_toupper(src[i]);74 dst[i] = (char)av_toupper(src[i]);
74 dst[i] = 0;75 dst[i] = 0;
75 return dst;76 return dst;
76}77}
@@ -106,6 +107,9 @@ static void default_print_section_footer(AVTextFormatContext *wctx) · 29 unmodified lines
106 const struct AVTextFormatSection *section = wctx->section[wctx->level];107 const struct AVTextFormatSection *section = wctx->section[wctx->level];
107 char buf[32];108 char buf[32];
108 109
110 if (!section)
111 return;
112
109 if (def->noprint_wrappers || def->nested_section[wctx->level])113 if (def->noprint_wrappers || def->nested_section[wctx->level])
110 return;114 return;
111 115
fftools/textformat/tf_ini.c+1−1
@@ -91,7 +91,7 @@ static char *ini_escape_str(AVBPrint *dst, const char *src) · 90 unmodified lines
91 /* fallthrough */91 /* fallthrough */
92 default:92 default:
93 if ((unsigned char)c < 32)93 if ((unsigned char)c < 32)
94 av_bprintf(dst, "\\x00%02x", c & 0xff);94 av_bprintf(dst, "\\x00%02x", (unsigned char)c);
95 else95 else
96 av_bprint_chars(dst, c, 1);96 av_bprint_chars(dst, c, 1);
97 break;97 break;
fftools/textformat/tf_json.c+10−7
@@ -80,13 +80,18 @@ static const char *json_escape_str(AVBPrint *dst, const char *src, void *log_ctx · 79 unmodified lines
80 static const char json_subst[] = { '"', '\\', 'b', 'f', 'n', 'r', 't', 0 };80 static const char json_subst[] = { '"', '\\', 'b', 'f', 'n', 'r', 't', 0 };
81 const char *p;81 const char *p;
82 82
83 if (!src) {
84 av_log(log_ctx, AV_LOG_WARNING, "Cannot escape NULL string, returning NULL\n");
85 return NULL;
86 }
87
83 for (p = src; *p; p++) {88 for (p = src; *p; p++) {
84 char *s = strchr(json_escape, *p);89 char *s = strchr(json_escape, *p);
85 if (s) {90 if (s) {
86 av_bprint_chars(dst, '\\', 1);91 av_bprint_chars(dst, '\\', 1);
87 av_bprint_chars(dst, json_subst[s - json_escape], 1);92 av_bprint_chars(dst, json_subst[s - json_escape], 1);
88 } else if ((unsigned char)*p < 32) {93 } else if ((unsigned char)*p < 32) {
89 av_bprintf(dst, "\\u00%02x", *p & 0xff);94 av_bprintf(dst, "\\u00%02x", (unsigned char)*p);
90 } else {95 } else {
91 av_bprint_chars(dst, *p, 1);96 av_bprint_chars(dst, *p, 1);
92 }97 }
@@ -100,11 +105,10 @@ static void json_print_section_header(AVTextFormatContext *wctx, const void *dat · 7 unmodified lines
100{105{
101 JSONContext *json = wctx->priv;106 JSONContext *json = wctx->priv;
102 AVBPrint buf;107 AVBPrint buf;
103 const struct AVTextFormatSection *section = wctx->section[wctx->level];108 const AVTextFormatSection *section = wctx->section[wctx->level];
104 const struct AVTextFormatSection *parent_section = wctx->level ?109 const AVTextFormatSection *parent_section = wctx->level ? wctx->section[wctx->level - 1] : NULL;
105 wctx->section[wctx->level-1] : NULL;
106 110
107 if (wctx->level && wctx->nb_item[wctx->level-1])111 if (wctx->level && wctx->nb_item[wctx->level - 1])
108 writer_put_str(wctx, ",\n");112 writer_put_str(wctx, ",\n");
109 113
110 if (section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER) {114 if (section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER) {
@@ -185,8 +189,7 @@ static void json_print_str(AVTextFormatContext *wctx, const char *key, const cha · 74 unmodified lines
185static void json_print_int(AVTextFormatContext *wctx, const char *key, int64_t value)189static void json_print_int(AVTextFormatContext *wctx, const char *key, int64_t value)
186{190{
187 JSONContext *json = wctx->priv;191 JSONContext *json = wctx->priv;
188 const struct AVTextFormatSection *parent_section = wctx->level ?192 const AVTextFormatSection *parent_section = wctx->level ? wctx->section[wctx->level - 1] : NULL;
189 wctx->section[wctx->level-1] : NULL;
190 AVBPrint buf;193 AVBPrint buf;
191 194
192 if (wctx->nb_item[wctx->level] || (parent_section && parent_section->flags & AV_TEXTFORMAT_SECTION_FLAG_NUMBERING_BY_TYPE))195 if (wctx->nb_item[wctx->level] || (parent_section && parent_section->flags & AV_TEXTFORMAT_SECTION_FLAG_NUMBERING_BY_TYPE))
fftools/textformat/tf_xml.c+0−3
@@ -18,10 +18,7 @@ · 17 unmodified lines
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */19 */
20 20
21#include <limits.h>
22#include <stdarg.h>
23#include <stdint.h>21#include <stdint.h>
24#include <stdio.h>
25#include <string.h>22#include <string.h>
26 23
27#include "avtextformat.h"24#include "avtextformat.h"
fftools/textformat/tw_avio.c+8−1
@@ -23,6 +23,7 @@ · 22 unmodified lines
23#include <string.h>23#include <string.h>
24 24
25#include "avtextwriters.h"25#include "avtextwriters.h"
26#include "libavutil/avassert.h"
26 27
27#include "libavutil/error.h"28#include "libavutil/error.h"
28 29
@@ -53,7 +54,7 @@ static void io_w8(AVTextWriterContext *wctx, int b) · 24 unmodified lines
53static void io_put_str(AVTextWriterContext *wctx, const char *str)54static void io_put_str(AVTextWriterContext *wctx, const char *str)
54{55{
55 IOWriterContext *ctx = wctx->priv;56 IOWriterContext *ctx = wctx->priv;
56 avio_write(ctx->avio_context, str, strlen(str));57 avio_write(ctx->avio_context, (const unsigned char *)str, (int)strlen(str));
57}58}
58 59
59static void io_printf(AVTextWriterContext *wctx, const char *fmt, ...)60static void io_printf(AVTextWriterContext *wctx, const char *fmt, ...)
@@ -81,6 +82,10 @@ int avtextwriter_create_file(AVTextWriterContext **pwctx, const char *output_fil · 21 unmodified lines
81 IOWriterContext *ctx;82 IOWriterContext *ctx;
82 int ret;83 int ret;
83 84
85 if (!output_filename || !output_filename[0]) {
86 av_log(NULL, AV_LOG_ERROR, "The output_filename cannot be NULL or empty\n");
87 return AVERROR(EINVAL);
88 }
84 89
85 ret = avtextwriter_context_open(pwctx, &avtextwriter_avio);90 ret = avtextwriter_context_open(pwctx, &avtextwriter_avio);
86 if (ret < 0)91 if (ret < 0)
@@ -106,6 +111,8 @@ int avtextwriter_create_avio(AVTextWriterContext **pwctx, AVIOContext *avio_ctx, · 19 unmodified lines
106 IOWriterContext *ctx;111 IOWriterContext *ctx;
107 int ret;112 int ret;
108 113
114 av_assert0(avio_ctx);
115
109 ret = avtextwriter_context_open(pwctx, &avtextwriter_avio);116 ret = avtextwriter_context_open(pwctx, &avtextwriter_avio);
110 if (ret < 0)117 if (ret < 0)
111 return ret;118 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t