Memory leak in object_find_unknown_rune()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PowerWyrm
    Prophet
    • Apr 2008
    • 2986

    Memory leak in object_find_unknown_rune()

    poss_runes is allocated but not freed in object_find_unknown_rune():

    Code:
    	int *poss_runes = mem_zalloc(rune_max * sizeof(int));
    
    	if (object_runes_known(obj)) return -1;
    
    	for (i = 0; i < rune_max; i++)
    		if (object_has_rune(obj, i) && !player_knows_rune(p, i))
    			poss_runes[num++] = i;
    
    	/* Grab a random rune from among the unknowns  */
    	if (num) return poss_runes[randint0(num)];
    
    	return -1;
    PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
  • Nick
    Vanilla maintainer
    • Apr 2007
    • 9637

    #2
    Nice work as usual
    One for the Dark Lord on his dark throne
    In the Land of Mordor where the Shadows lie.

    Comment

    Working...
    😀
    😂
    🥰
    😘
    🤢
    😎
    😞
    😡
    👍
    👎