Fix memory overwrite in macParseDefns

This commit is contained in:
Freddie Akeroyd authored and Dirk Zimoch committed 2026-11-03 16:17:46 +01:00
1 parent fa278858b7
commit eed6855383
1 file changed
+5 -2
+5 -2
View File
@@ -62,8 +62,11 @@ epicsStdCall macParseDefns(
printf( "macParseDefns( %s )\n", defns );
/* allocate temporary pointer arrays; in worst case they need to have
as many entries as the length of the defns string */
numMax = strlen( defns );
as many entries as the length of the defns string + 2
for defns="1,3,5" give 3 pairs so num will be 6 (strlen(defns)+1)
but as num is used as an index e.g. del[num] we need
numMax to be strlen(defns) + 2 */
numMax = strlen( defns ) + 2;
if ( numMax < altNumMax )
numMax = altNumMax;
ptr = (const char **) calloc( numMax, sizeof( char * ) );