Fix a small memory leak in raop_buffer.
[deb_shairplay.git] / src / lib / raop_buffer.c
index b9b52afa2feb6929368933bd8d4a6833f6c0e129..38995c220bd21ae0837461ec75ce46f903aacdeb 100644 (file)
@@ -72,20 +72,21 @@ static int
 get_fmtp_info(ALACSpecificConfig *config, const char *fmtp)
 {
        int intarr[12];
+       char *original;
        char *strptr;
        int i;
 
        /* Parse fmtp string to integers */
-       strptr = strdup(fmtp);
+       original = strptr = strdup(fmtp);
        for (i=0; i<12; i++) {
                if (strptr == NULL) {
-                       free(strptr);
+                       free(original);
                        return -1;
                }
                intarr[i] = atoi(utils_strsep(&strptr, " "));
        }
-       free(strptr);
-       strptr = NULL;
+       free(original);
+       original = strptr = NULL;
 
        /* Fill the config struct */
        config->frameLength = intarr[1];
@@ -211,8 +212,8 @@ void
 raop_buffer_destroy(raop_buffer_t *raop_buffer)
 {
        if (raop_buffer) {
+               destroy_alac(raop_buffer->alac);
                free(raop_buffer->buffer);
-               free(raop_buffer->alac);
                free(raop_buffer);
        }
 }