Null-check app_get_resource_path() 07/307707/1 accepted/tizen/7.0/unified/20240314.152318
authorArtur Świgoń <a.swigon@samsung.com>
Tue, 12 Mar 2024 09:07:01 +0000 (10:07 +0100)
committerArtur Świgoń <a.swigon@samsung.com>
Tue, 12 Mar 2024 09:45:27 +0000 (09:45 +0000)
The return value is passed as the first argument to g_strconcat(), which
expects a NULL-terminated argument list, but its documentation
explicitly states that the first argument must be non-NULL.

Change-Id: I2bfab7540fd0e717007399ed5e41fece644979e0
(cherry picked from commit c71069943dc61d7332eefbca6a0b2d0fb8b53074)

src/smart_notification.c

index e814c4aeb5a3817e232d6c47d0baad284a517a56..d24dd276716a3f1302cd63ec08a14964c7d05216 100644 (file)
@@ -43,8 +43,10 @@ static AtspiEventListener *listener = NULL;
 
 static char *_get_sound_path(const char *file_path)
 {
-       char *dir;
-       dir = app_get_resource_path();
+       char *dir = app_get_resource_path();
+       if (!dir)
+               return NULL;
+
        char *path = g_strconcat(dir, "sounds/", file_path, NULL);
        g_free(dir);
        DEBUG("path: (%s)", path);
@@ -54,11 +56,12 @@ static char *_get_sound_path(const char *file_path)
 static void _play_sound(const char *file)
 {
        gchar *wav_path = _get_sound_path(file);
-       if (wav_path)
-       {
+       if (wav_path) {
                mm_sound_play_keysound(wav_path, VOLUME_TYPE_MEDIA);
+               g_free(wav_path);
+       } else {
+               ERROR("Cannot play sound, the sound path is null");
        }
-       g_free(wav_path);
 }
 
 /**