wmgeneral: Check if malloc fails.
Fixes "(error) Uninitialized variable: ret" found by cppcheck.
This commit is contained in:
		
							parent
							
								
									fdb596cd42
								
							
						
					
					
						commit
						746c4b6b7c
					
				
					 10 changed files with 51 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										5
									
								
								wmcpufreq/wmgeneral/misc.c
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										5
									
								
								wmcpufreq/wmgeneral/misc.c
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
    
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
	int state, ctype;
 | 
			
		||||
 | 
			
		||||
	t = ret = malloc(strlen(word)+1);
 | 
			
		||||
	if (ret == NULL) {
 | 
			
		||||
		fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
		exit(EXIT_FAILURE);
 | 
			
		||||
	}
 | 
			
		||||
	ptr = word;
 | 
			
		||||
 | 
			
		||||
	state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,11 +16,12 @@
 | 
			
		|||
 *
 | 
			
		||||
 *  You should have received a copy of the GNU General Public License
 | 
			
		||||
 *  along with this program; if not, write to the Free Software
 | 
			
		||||
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
			
		||||
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,6 +64,10 @@ next_token(char *word, char **next)
 | 
			
		|||
    int state, ctype;
 | 
			
		||||
 | 
			
		||||
    t = ret = malloc(strlen(word)+1);
 | 
			
		||||
    if (ret == NULL) {
 | 
			
		||||
	    fprintf(stderr, "Insufficient memory.\n");
 | 
			
		||||
	    exit(EXIT_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = word;
 | 
			
		||||
 | 
			
		||||
    state = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue