Skip to content

Commit 4d5eea5

Browse files
authored
Cppcheck fixes (#47)
* possible memory leak checks * update README.md
1 parent bb5609b commit 4d5eea5

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
44
[![GitHub release](https://img.shields.io/github/release/barrust/c-utils.svg)](https://github.com/barrust/c-utils/releases)
5-
[![Build Status](https://travis-ci.org/barrust/c-utils.svg?branch=master)](https://travis-ci.org/barrust/c-utils)
5+
[![Build Status](https://github.com/barrust/c-utils/workflows/C/C++%20CI/badge.svg)](https://github.com/barrust/c-utils/actions)
66
[![codecov](https://codecov.io/gh/barrust/c-utils/branch/master/graph/badge.svg)](https://codecov.io/gh/barrust/c-utils)
77

88

9-
109
This project provides a collection of utility libraries to help reduce the need to write similar code for each project on an ad-hoc basis. The need is based on what I have needed in most projects but are ended up written, as needed, and usually differently each time and without unit tests. The goal is to provide a single place to store each of these libraries and to provide unit tests.
1110

1211
If there are other commonly used code or data-structures that should be added, please add a feature request!

src/fileutils.c

+2
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,8 @@ static char** __str_split_string_any(char* s, const char* s2, size_t* num) {
824824
*num = cnt;
825825

826826
char** v = (char**)realloc(results, cnt * sizeof(char*));
827+
if (v == NULL)
828+
return results;
827829
return v;
828830
}
829831

src/stringlib.c

+6
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ char** s_split_string_c(const char* s, const char c, int* num) {
479479
*num = cnt;
480480

481481
char** v = (char**)realloc(results, cnt * sizeof(char*));
482+
if (v == NULL)
483+
return results;
482484
return v;
483485
}
484486

@@ -511,6 +513,8 @@ char** s_split_string_str(const char* s, const char* sub, int* num) {
511513
*num = cnt;
512514

513515
char** v = (char**)realloc(results, cnt * sizeof(char*));
516+
if (v == NULL)
517+
return results;
514518
return v;
515519
}
516520

@@ -545,6 +549,8 @@ char** s_split_string_any(const char* s, const char* s2, int* num) {
545549
*num = cnt;
546550

547551
char** v = (char**)realloc(results, cnt * sizeof(char*));
552+
if (v == NULL)
553+
return results;
548554
return v;
549555
}
550556

0 commit comments

Comments
 (0)