Skip to content

Commit

Permalink
spdx: Fix possible crash when NULL is passed to is_free_license
Browse files Browse the repository at this point in the history
  • Loading branch information
ximion committed Aug 16, 2022
1 parent c463d68 commit 1522caf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/as-spdx.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ as_is_spdx_license_expression (const gchar *license)
gboolean expect_exception = FALSE;

/* handle nothing set */
if (license == NULL || license[0] == '\0')
if (as_is_empty (license))
return FALSE;

/* no license information whatsoever */
Expand Down Expand Up @@ -744,13 +744,18 @@ as_license_is_free_license (const gchar *license)
g_autoptr(GBytes) rdata = NULL;
gboolean is_free;

/* no license at all is "non-free" */
if (as_is_empty (license))
return FALSE;
if (g_strcmp0 (license, "NONE") == 0)
return FALSE;

/* load the readonly data section of (free) license IDs */
rdata = g_resource_lookup_data (as_get_resource (),
"/org/freedesktop/appstream/spdx-free-license-ids.txt",
G_RESOURCE_LOOKUP_FLAGS_NONE,
NULL);
if (rdata == NULL)
return FALSE;
g_return_val_if_fail (rdata != NULL, FALSE);

/* assume we have a free software license, unless proven otherwise */
is_free = TRUE;
Expand Down

0 comments on commit 1522caf

Please sign in to comment.