mirror of
				https://github.com/raysan5/raylib.git
				synced 2025-10-26 12:27:01 +00:00 
			
		
		
		
	fix various problems, thanks CppCheck :) (#1005)
* explained a bit more the core_window_letterbox example * fixed a few 'ups' moments that could lead to mild head pain and time loss
This commit is contained in:
		| @@ -929,12 +929,16 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount) | ||||
|     { | ||||
|         TraceLog(LOG_ERROR, "Magic Number \"%s\"does not match.", iqm.magic); | ||||
|         fclose(iqmFile); | ||||
|  | ||||
|         return NULL; | ||||
|     } | ||||
|  | ||||
|     if (iqm.version != IQM_VERSION) | ||||
|     { | ||||
|         TraceLog(LOG_ERROR, "IQM version %i is incorrect.", iqm.version); | ||||
|         fclose(iqmFile); | ||||
|          | ||||
|         return NULL; | ||||
|     } | ||||
|  | ||||
|     // Get bones data | ||||
|   | ||||
							
								
								
									
										19
									
								
								src/physac.h
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								src/physac.h
									
									
									
									
									
								
							| @@ -842,10 +842,18 @@ PHYSACDEF void DestroyPhysicsBody(PhysicsBody body) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|          | ||||
|         if (index == -1){ | ||||
|  | ||||
|             #if defined(PHYSAC_DEBUG) | ||||
|         if (index == -1) printf("[PHYSAC] cannot find body id %i in pointers array\n", id); | ||||
|                 printf("[PHYSAC] cannot find body id %i in pointers array\n", id); | ||||
|             #endif | ||||
|  | ||||
|         // prevent access to index -1 | ||||
|         return; | ||||
|         }  | ||||
|          | ||||
|  | ||||
|         // Free body allocated memory | ||||
|         PHYSAC_FREE(body); | ||||
|         usedMemory -= sizeof(PhysicsBodyData); | ||||
| @@ -1249,10 +1257,17 @@ static void DestroyPhysicsManifold(PhysicsManifold manifold) | ||||
|             } | ||||
|         } | ||||
|  | ||||
|  | ||||
|         if (index == -1) { | ||||
|             #if defined(PHYSAC_DEBUG) | ||||
|             if (index == -1) printf("[PHYSAC] cannot find manifold id %i in pointers array\n", id); | ||||
|                 printf("[PHYSAC] cannot find manifold id %i in pointers array\n", id); | ||||
|             #endif | ||||
|  | ||||
|             //prevent access to index -1 | ||||
|             return; | ||||
|         }  | ||||
|          | ||||
|  | ||||
|         // Free manifold allocated memory | ||||
|         PHYSAC_FREE(manifold); | ||||
|         usedMemory -= sizeof(PhysicsManifoldData); | ||||
|   | ||||
| @@ -592,7 +592,6 @@ void SetMasterVolume(float volume) | ||||
| AudioBuffer *InitAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 bufferSizeInFrames, int usage) | ||||
| { | ||||
|     AudioBuffer *audioBuffer = (AudioBuffer *)RL_CALLOC(1, sizeof(AudioBuffer)); | ||||
|     audioBuffer->buffer = RL_CALLOC(bufferSizeInFrames*channels*ma_get_bytes_per_sample(format), 1); | ||||
|  | ||||
|     if (audioBuffer == NULL) | ||||
|     { | ||||
| @@ -600,6 +599,8 @@ AudioBuffer *InitAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sam | ||||
|         return NULL; | ||||
|     } | ||||
|      | ||||
|     audioBuffer->buffer = RL_CALLOC(bufferSizeInFrames*channels*ma_get_bytes_per_sample(format), 1); | ||||
|  | ||||
|     // Audio data runs through a format converter | ||||
|     ma_pcm_converter_config dspConfig; | ||||
|     memset(&dspConfig, 0, sizeof(dspConfig)); | ||||
|   | ||||
| @@ -1887,6 +1887,13 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi | ||||
| #endif | ||||
| #endif      // GRAPHICS_API_OPENGL_11 | ||||
|  | ||||
|     if( data == NULL ){ | ||||
|         //ups! | ||||
|         TraceLog(LOG_WARNING, "Got asked to load texture from a NULL pointer!"); | ||||
|  | ||||
|         return id; | ||||
|     } | ||||
|  | ||||
|     glPixelStorei(GL_UNPACK_ALIGNMENT, 1); | ||||
|  | ||||
|     glGenTextures(1, &id);              // Generate texture id | ||||
|   | ||||
| @@ -1524,7 +1524,7 @@ static float EaseCubicInOut(float t, float b, float c, float d) | ||||
| // Get texture to draw shapes (RAII) | ||||
| static Texture2D GetShapesTexture(void) | ||||
| { | ||||
|     if (texShapes.id <= 0) | ||||
|      if (texShapes.id == 0) //this variable is an unsigned int, will never be negative | ||||
|     { | ||||
| #if defined(SUPPORT_FONT_TEXTURE) | ||||
|         texShapes = GetFontDefault().texture;           // Use font texture white character | ||||
|   | ||||
| @@ -1394,7 +1394,7 @@ char *TextToUtf8(int *codepoints, int length) | ||||
|     } | ||||
|      | ||||
|     // Resize memory to text length + string NULL terminator | ||||
|     realloc(text, size + 1); | ||||
|     text = realloc(text, size + 1); | ||||
|      | ||||
|     return text; | ||||
| } | ||||
|   | ||||
| @@ -662,7 +662,7 @@ Vector4 *GetImageDataNormalized(Image image) | ||||
|                     pixels[i].w = 1.0f; | ||||
|  | ||||
|                     k += 3; | ||||
|                 } | ||||
|                 } break; | ||||
|                 case UNCOMPRESSED_R32G32B32A32: | ||||
|                 { | ||||
|                     pixels[i].x = ((float *)image.data)[k]; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 João Coelho
					João Coelho