This should be safe. The 'potential leak of memory' warning probably was not justified, but still I think the code is cleaner this way.