]> granicus.if.org Git - php/commitdiff
Refactored the previous memleak fix
authorAnatol Belski <ab@php.net>
Mon, 8 Apr 2013 12:32:37 +0000 (14:32 +0200)
committerAnatol Belski <ab@php.net>
Mon, 8 Apr 2013 12:32:37 +0000 (14:32 +0200)
to avoid usage of a freed pointer. Thanks Laruence )

ext/fileinfo/libmagic/apprentice.c

index 06d28ad5c777af043641b72cde14ec4f638963e7..0620fc7f93524b0e4ead61e36dfab5a5040baaa4 100644 (file)
@@ -492,15 +492,15 @@ apprentice_unmap(struct magic_map *map)
 {
        if (map == NULL)
                return;
-       if (map->p != NULL && map->p != php_magic_database) {
-               efree(map->p);
-       }
        if (map->p != php_magic_database) {
                int j;
                for (j = 0; j < MAGIC_SETS; j++) {
                        if (map->magic[j])
                                efree(map->magic[j]);
                }
+               if (map->p != NULL) {
+                       efree(map->p);
+               }
        }
        efree(map);
 }