Skip to content

Commit

Permalink
hdf-eos: fix potential nullptr deref
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Nov 27, 2024
1 parent 01b9c92 commit 4cfbcf8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frmts/hdf4/hdf-eos/EHapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ EHmetagroup(int32 sdInterfaceID, const char *structname, const char *structcode,
int32 metalen; /* Length of structural metadata */

char *metabuf; /* Pointer (handle) to structural metadata */
char *endptr; /* Pointer to end of metadata section */
char *endptr = NULL; /* Pointer to end of metadata section */
char *metaptr; /* Metadata pointer */
char *prevmetaptr;/* Previous position of metadata pointer */
char *utlstr; /* Utility string */
Expand Down Expand Up @@ -1605,7 +1605,7 @@ EHmetagroup(int32 sdInterfaceID, const char *structname, const char *structcode,
}
/* Find group within structure */
/* --------------------------- */
if (groupname != NULL)
if (metaptr && groupname != NULL)
{
snprintf(utlstr, UTLSTR_MAX_SIZE, "%s%s", "GROUP=", groupname);
metaptr = strstr(metaptr, utlstr);
Expand All @@ -1615,7 +1615,7 @@ EHmetagroup(int32 sdInterfaceID, const char *structname, const char *structcode,
endptr = strstr(metaptr, utlstr);
else
endptr = NULL;
} else
} else if (metaptr)
{
/* If groupname == NULL then find end of structure in metadata */
/* ----------------------------------------------------------- */
Expand Down

0 comments on commit 4cfbcf8

Please sign in to comment.