Fix an obscure memory leak and fix formatting.

This patch fixes an obscure memory leak and make the formatting
of these two routines match the rest of the code in the file.
(cherry picked from commit 7866e92761)
This commit is contained in:
Cary R 2010-01-22 19:44:56 -08:00 committed by Stephen Williams
parent 8fc049eefd
commit c337b0ef0c
1 changed files with 29 additions and 26 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -111,7 +111,10 @@ char *generic_get_str(int code, vpiHandle ref, const char *name, const char *ind
if (index != NULL) len += strlen(index) + 2; /* include space for brackets */
char *res = need_result_buf(len, RBUF_STR);
if (!res) return NULL;
if (!res) {
free(bn);
return NULL;
}
*res=0; /* start with nothing */
/* if this works, I can make it more efficient later */