FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavutil/avstring.c
Date: 2026-10-15 10:36:02
Exec Total Coverage
Lines: 227 250 90.8%
Functions: 20 20 100.0%
Branches: 167 210 79.5%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
3 * Copyright (c) 2007 Mans Rullgard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <limits.h>
23 #include <stdarg.h>
24 #include <stdint.h>
25 #include <stdio.h>
26 #include <string.h>
27
28 #include "config.h"
29 #include "mem.h"
30 #include "avassert.h"
31 #include "avstring.h"
32 #include "bprint.h"
33 #include "error.h"
34 #include "macros.h"
35
36 204052706 int av_strstart(const char *str, const char *pfx, const char **ptr)
37 {
38
4/4
✓ Branch 0 taken 221904250 times.
✓ Branch 1 taken 1401107 times.
✓ Branch 2 taken 19252651 times.
✓ Branch 3 taken 202651599 times.
223305357 while (*pfx && *pfx == *str) {
39 19252651 pfx++;
40 19252651 str++;
41 }
42
4/4
✓ Branch 0 taken 1401107 times.
✓ Branch 1 taken 202651599 times.
✓ Branch 2 taken 1400094 times.
✓ Branch 3 taken 1013 times.
204052706 if (!*pfx && ptr)
43 1400094 *ptr = str;
44 204052706 return !*pfx;
45 }
46
47 14490 int av_stristart(const char *str, const char *pfx, const char **ptr)
48 {
49
4/4
✓ Branch 0 taken 15897 times.
✓ Branch 1 taken 314 times.
✓ Branch 2 taken 1721 times.
✓ Branch 3 taken 14176 times.
16211 while (*pfx && av_toupper((unsigned)*pfx) == av_toupper((unsigned)*str)) {
50 1721 pfx++;
51 1721 str++;
52 }
53
4/4
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 14176 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 310 times.
14490 if (!*pfx && ptr)
54 4 *ptr = str;
55 14490 return !*pfx;
56 }
57
58 850 char *av_stristr(const char *s1, const char *s2)
59 {
60
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 850 times.
850 if (!*s2)
61 ✗ return (char*)(intptr_t)s1;
62
63 do
64
2/2
✓ Branch 1 taken 310 times.
✓ Branch 2 taken 14161 times.
14471 if (av_stristart(s1, s2, NULL))
65 310 return (char*)(intptr_t)s1;
66
2/2
✓ Branch 0 taken 13621 times.
✓ Branch 1 taken 540 times.
14161 while (*s1++);
67
68 540 return NULL;
69 }
70
71 8 char *av_strnstr(const char *haystack, const char *needle, size_t hay_length)
72 {
73 8 size_t needle_len = strlen(needle);
74
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
8 if (!needle_len)
75 1 return (char*)haystack;
76
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 1 times.
354 while (hay_length >= needle_len) {
77 353 hay_length--;
78
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 347 times.
353 if (!memcmp(haystack, needle, needle_len))
79 6 return (char*)haystack;
80 347 haystack++;
81 }
82 1 return NULL;
83 }
84
85 404478 size_t av_strlcpy(char *dst, const char *src, size_t size)
86 {
87 404478 size_t len = 0;
88
4/4
✓ Branch 0 taken 2505774 times.
✓ Branch 1 taken 135718 times.
✓ Branch 2 taken 2237014 times.
✓ Branch 3 taken 268760 times.
2641492 while (++len < size && *src)
89 2237014 *dst++ = *src++;
90
1/2
✓ Branch 0 taken 404478 times.
✗ Branch 1 not taken.
404478 if (len <= size)
91 404478 *dst = 0;
92 404478 return len + strlen(src) - 1;
93 }
94
95 67526 size_t av_strlcat(char *dst, const char *src, size_t size)
96 {
97 67526 size_t len = strlen(dst);
98
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67526 times.
67526 if (size <= len + 1)
99 ✗ return len + strlen(src);
100 67526 return len + av_strlcpy(dst + len, src, size - len);
101 }
102
103 162529 size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...)
104 {
105 162529 size_t len = strlen(dst);
106 va_list vl;
107
108 162529 va_start(vl, fmt);
109
1/2
✓ Branch 0 taken 162529 times.
✗ Branch 1 not taken.
162529 len += vsnprintf(dst + len, size > len ? size - len : 0, fmt, vl);
110 162529 va_end(vl);
111
112 162529 return len;
113 }
114
115 18149 char *av_asprintf(const char *fmt, ...)
116 {
117 18149 char *p = NULL;
118 va_list va;
119 int len;
120
121 18149 va_start(va, fmt);
122 18149 len = vsnprintf(NULL, 0, fmt, va);
123 18149 va_end(va);
124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18149 times.
18149 if (len < 0)
125 ✗ goto end;
126
127 18149 p = av_malloc(len + 1);
128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18149 times.
18149 if (!p)
129 ✗ goto end;
130
131 18149 va_start(va, fmt);
132 18149 len = vsnprintf(p, len + 1, fmt, va);
133 18149 va_end(va);
134
1/2
✓ Branch 0 taken 18149 times.
✗ Branch 1 not taken.
18149 if (len < 0)
135 ✗ av_freep(&p);
136
137 18149 end:
138 18149 return p;
139 }
140
141 #define WHITESPACES " \n\t\r"
142
143 129660 char *av_get_token(const char **buf, const char *term)
144 {
145 129660 char *out = av_realloc(NULL, strlen(*buf) + 1);
146 129660 char *ret = out, *end = out;
147 129660 const char *p = *buf;
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129660 times.
129660 if (!out)
149 ✗ return NULL;
150 129660 p += strspn(p, WHITESPACES);
151
152
4/4
✓ Branch 0 taken 1321226 times.
✓ Branch 1 taken 47567 times.
✓ Branch 2 taken 1239133 times.
✓ Branch 3 taken 82093 times.
1368793 while (*p && !strspn(p, term)) {
153 1239133 char c = *p++;
154
4/4
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 1238898 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2 times.
1239133 if (c == '\\' && *p) {
155 233 *out++ = *p++;
156 233 end = out;
157
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1238846 times.
1238900 } else if (c == '\'') {
158
4/4
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 882 times.
✓ Branch 3 taken 50 times.
936 while (*p && *p != '\'')
159 882 *out++ = *p++;
160
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 4 times.
54 if (*p) {
161 50 p++;
162 50 end = out;
163 }
164 } else {
165 1238846 *out++ = c;
166 }
167 }
168
169 do
170 130134 *out-- = 0;
171
4/4
✓ Branch 0 taken 128232 times.
✓ Branch 1 taken 1902 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 127758 times.
130134 while (out >= end && strspn(out, WHITESPACES));
172
173 129660 *buf = p;
174
175 129660 char *small_ret = av_realloc(ret, out - ret + 2);
176
1/2
✓ Branch 0 taken 129660 times.
✗ Branch 1 not taken.
129660 return small_ret ? small_ret : ret;
177 }
178
179 10814 char *av_strtok(char *s, const char *delim, char **saveptr)
180 {
181 char *tok;
182
183
4/4
✓ Branch 0 taken 9025 times.
✓ Branch 1 taken 1789 times.
✓ Branch 2 taken 505 times.
✓ Branch 3 taken 8520 times.
10814 if (!s && !(s = *saveptr))
184 505 return NULL;
185
186 /* skip leading delimiters */
187 10309 s += strspn(s, delim);
188
189 /* s now points to the first non delimiter char, or to the end of the string */
190
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 10280 times.
10309 if (!*s) {
191 29 *saveptr = NULL;
192 29 return NULL;
193 }
194 10280 tok = s++;
195
196 /* skip non delimiters */
197 10280 s += strcspn(s, delim);
198
2/2
✓ Branch 0 taken 8856 times.
✓ Branch 1 taken 1424 times.
10280 if (*s) {
199 8856 *s = 0;
200 8856 *saveptr = s+1;
201 } else {
202 1424 *saveptr = NULL;
203 }
204
205 10280 return tok;
206 }
207
208 698935 int av_strcasecmp(const char *a, const char *b)
209 {
210 uint8_t c1, c2;
211 do {
212 776174 c1 = av_tolower(*a++);
213 776174 c2 = av_tolower(*b++);
214
4/4
✓ Branch 0 taken 770567 times.
✓ Branch 1 taken 5607 times.
✓ Branch 2 taken 77239 times.
✓ Branch 3 taken 693328 times.
776174 } while (c1 && c1 == c2);
215 698935 return c1 - c2;
216 }
217
218 3896328 int av_strncasecmp(const char *a, const char *b, size_t n)
219 {
220 uint8_t c1, c2;
221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3896328 times.
3896328 if (n <= 0)
222 ✗ return 0;
223 do {
224 4257446 c1 = av_tolower(*a++);
225 4257446 c2 = av_tolower(*b++);
226
6/6
✓ Branch 0 taken 4212862 times.
✓ Branch 1 taken 44584 times.
✓ Branch 2 taken 4210734 times.
✓ Branch 3 taken 2128 times.
✓ Branch 4 taken 361118 times.
✓ Branch 5 taken 3849616 times.
4257446 } while (--n && c1 && c1 == c2);
227 3896328 return c1 - c2;
228 }
229
230 6 char *av_strireplace(const char *str, const char *from, const char *to)
231 {
232 6 char *ret = NULL;
233 6 const char *pstr2, *pstr = str;
234 6 size_t tolen = strlen(to), fromlen = strlen(from);
235 AVBPrint pbuf;
236
237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (!fromlen)
238 ✗ return av_strdup(str);
239
240 6 av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
241
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
12 while ((pstr2 = av_stristr(pstr, from))) {
242 6 av_bprint_append_data(&pbuf, pstr, pstr2 - pstr);
243 6 pstr = pstr2 + fromlen;
244 6 av_bprint_append_data(&pbuf, to, tolen);
245 }
246 6 av_bprint_append_data(&pbuf, pstr, strlen(pstr));
247
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
6 if (!av_bprint_is_complete(&pbuf)) {
248 ✗ av_bprint_finalize(&pbuf, NULL);
249 } else {
250 6 av_bprint_finalize(&pbuf, &ret);
251 }
252
253 6 return ret;
254 }
255
256 196 const char *av_basename(const char *path)
257 {
258
2/4
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
196 if (!path || *path == '\0')
259 ✗ return ".";
260
261 196 const char *p = strrchr(path, '/');
262 #if HAVE_DOS_PATHS
263 const char *q = strrchr(path, '\\');
264 const char *d = strchr(path, ':');
265 p = FFMAX3(p, q, d);
266 #endif
267
268
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 190 times.
196 if (!p)
269 6 return path;
270
271 190 return p + 1;
272 }
273
274 55 const char *av_dirname(char *path)
275 {
276
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 char *p = path ? strrchr(path, '/') : NULL;
277
278 #if HAVE_DOS_PATHS
279 char *q = path ? strrchr(path, '\\') : NULL;
280 char *d = path ? strchr(path, ':') : NULL;
281
282 d = d ? d + 1 : d;
283
284 p = FFMAX3(p, q, d);
285 #endif
286
287
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 51 times.
55 if (!p)
288 4 return ".";
289
290 51 *p = '\0';
291
292 51 return path;
293 }
294
295 9 char *av_append_path_component(const char *path, const char *component)
296 {
297 size_t p_len, c_len;
298 char *fullpath;
299
300
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if (!path)
301 2 return av_strdup(component);
302
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
7 if (!component)
303 1 return av_strdup(path);
304
305 6 p_len = strlen(path);
306 6 c_len = strlen(component);
307
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if (p_len > SIZE_MAX - c_len || p_len + c_len > SIZE_MAX - 2)
308 ✗ return NULL;
309 6 fullpath = av_malloc(p_len + c_len + 2);
310
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (fullpath) {
311
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (p_len) {
312 6 av_strlcpy(fullpath, path, p_len + 1);
313
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (c_len) {
314
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
6 if (fullpath[p_len - 1] != '/' && component[0] != '/')
315 2 fullpath[p_len++] = '/';
316
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
4 else if (fullpath[p_len - 1] == '/' && component[0] == '/')
317 2 p_len--;
318 }
319 }
320 6 av_strlcpy(&fullpath[p_len], component, c_len + 1);
321 6 fullpath[p_len + c_len] = 0;
322 }
323 6 return fullpath;
324 }
325
326 139 int av_escape(char **dst, const char *src, const char *special_chars,
327 enum AVEscapeMode mode, int flags)
328 {
329 AVBPrint dstbuf;
330 int ret;
331
332 139 av_bprint_init(&dstbuf, 1, INT_MAX); /* (int)dstbuf.len must be >= 0 */
333 139 av_bprint_escape(&dstbuf, src, special_chars, mode, flags);
334
335
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
139 if (!av_bprint_is_complete(&dstbuf)) {
336 ✗ av_bprint_finalize(&dstbuf, NULL);
337 ✗ return AVERROR(ENOMEM);
338 }
339
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
139 if ((ret = av_bprint_finalize(&dstbuf, dst)) < 0)
340 ✗ return ret;
341 139 return dstbuf.len;
342 }
343
344 9103862 int av_match_name(const char *name, const char *names)
345 {
346 const char *p;
347 size_t len, namelen;
348
349
4/4
✓ Branch 0 taken 6118789 times.
✓ Branch 1 taken 2985073 times.
✓ Branch 2 taken 2714336 times.
✓ Branch 3 taken 3404453 times.
9103862 if (!name || !names)
350 5699409 return 0;
351
352 3404453 namelen = strlen(name);
353
2/2
✓ Branch 0 taken 3877785 times.
✓ Branch 1 taken 3386650 times.
7264435 while (*names) {
354 3877785 int negate = '-' == *names;
355 3877785 p = strchr(names, ',');
356
2/2
✓ Branch 0 taken 3402536 times.
✓ Branch 1 taken 475249 times.
3877785 if (!p)
357 3402536 p = names + strlen(names);
358 3877785 names += negate;
359 3877785 len = FFMAX(p - names, namelen);
360
3/4
✓ Branch 1 taken 3859982 times.
✓ Branch 2 taken 17803 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3859982 times.
3877785 if (!av_strncasecmp(name, names, len) || !strncmp("ALL", names, FFMAX(3, p - names)))
361 17803 return !negate;
362 3859982 names = p + (*p == ',');
363 }
364 3386650 return 0;
365 }
366
367 259385 int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end,
368 unsigned int flags)
369 {
370 259385 const uint8_t *p = *bufp;
371 uint32_t top;
372 uint64_t code;
373 259385 int ret = 0, tail_len;
374 259385 uint32_t overlong_encoding_mins[6] = {
375 0x00000000, 0x00000080, 0x00000800, 0x00010000, 0x00200000, 0x04000000,
376 };
377
378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259385 times.
259385 if (p >= buf_end)
379 ✗ return 0;
380
381 259385 code = *p++;
382
383 /* first sequence byte starts with 10, or is 1111-1110 or 1111-1111,
384 which is not admitted */
385
4/4
✓ Branch 0 taken 259383 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 259382 times.
259385 if ((code & 0xc0) == 0x80 || code >= 0xFE) {
386 3 ret = AVERROR(EILSEQ);
387 3 goto end;
388 }
389 259382 top = (code & 128) >> 1;
390
391 259382 tail_len = 0;
392
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 259380 times.
260185 while (code & top) {
393 int tmp;
394 805 tail_len++;
395
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 804 times.
805 if (p >= buf_end) {
396 1 (*bufp) ++;
397 1 return AVERROR(EILSEQ); /* incomplete sequence */
398 }
399
400 /* we assume the byte to be in the form 10xx-xxxx */
401 804 tmp = *p++ - 128; /* strip leading 1 */
402
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 803 times.
804 if (tmp>>6) {
403 1 (*bufp) ++;
404 1 return AVERROR(EILSEQ);
405 }
406 803 code = (code<<6) + tmp;
407 803 top <<= 5;
408 }
409 259380 code &= (top << 1) - 1;
410
411 /* check for overlong encodings */
412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259380 times.
259380 av_assert0(tail_len <= 5);
413
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 259378 times.
259380 if (code < overlong_encoding_mins[tail_len]) {
414 2 ret = AVERROR(EILSEQ);
415 2 goto end;
416 }
417
418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259378 times.
259378 if (code >= 1U<<31) {
419 ✗ ret = AVERROR(EILSEQ); /* out-of-range value */
420 ✗ goto end;
421 }
422
423 259378 *codep = code;
424
425
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 259376 times.
259378 if (code > 0x10FFFF &&
426
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 !(flags & AV_UTF8_FLAG_ACCEPT_INVALID_BIG_CODES))
427 2 ret = AVERROR(EILSEQ);
428
6/8
✓ Branch 0 taken 2017 times.
✓ Branch 1 taken 257361 times.
✓ Branch 2 taken 2017 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 91 times.
✓ Branch 5 taken 1926 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 91 times.
259378 if (code < 0x20 && code != 0x9 && code != 0xA && code != 0xD &&
429 ✗ flags & AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES)
430 ✗ ret = AVERROR(EILSEQ);
431
4/4
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 259057 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 320 times.
259378 if (code >= 0xD800 && code <= 0xDFFF &&
432
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 !(flags & AV_UTF8_FLAG_ACCEPT_SURROGATES))
433 1 ret = AVERROR(EILSEQ);
434
3/4
✓ Branch 0 taken 259378 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259377 times.
✓ Branch 3 taken 1 times.
259378 if ((code == 0xFFFE || code == 0xFFFF) &&
435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 !(flags & AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS))
436 1 ret = AVERROR(EILSEQ);
437
438 259377 end:
439 259383 *bufp = p;
440 259383 return ret;
441 }
442
443 206 int av_match_list(const char *name, const char *list, char separator)
444 {
445 const char *p, *q;
446
447
2/4
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206 times.
✗ Branch 3 not taken.
412 for (p = name; p && *p; ) {
448
2/4
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 212 times.
✗ Branch 3 not taken.
418 for (q = list; q && *q; ) {
449 int k;
450
5/6
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 206 times.
✗ Branch 5 not taken.
1036 for (k = 0; p[k] == q[k] || (p[k]*q[k] == 0 && p[k]+q[k] == separator); k++)
451
5/6
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 618 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
1030 if (k && (!p[k] || p[k] == separator))
452 206 return 1;
453 6 q = strchr(q, separator);
454
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(q)
455 6 q++;
456 }
457 ✗ p = strchr(p, separator);
458 ✗ if (p)
459 ✗ p++;
460 }
461
462 ✗ return 0;
463 }
464